Skip to content

Commit

Permalink
Merge pull request #6098 from onflow/fxamacker/fix-panic-diff-enum-ke…
Browse files Browse the repository at this point in the history
…y-in-diff-states-cmd

Fix panic in `diff-states` command when comparing enum dict key
  • Loading branch information
turbolent authored Jun 14, 2024
2 parents d32b10e + 4de2204 commit a8e97c1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/util/ledger/migrations/cadence_value_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ func (dr *CadenceValueDiffReporter) diffCadenceDictionaryValue(
return true
})

onlyOldKeys, onlyNewKeys, sharedKeys := diffCadenceValues(oldKeys, newKeys)
onlyOldKeys, onlyNewKeys, sharedKeys := diffCadenceValues(vInterpreter, oldKeys, newKeys)

// Log keys only present in old dict value
if len(onlyOldKeys) > 0 {
Expand Down Expand Up @@ -915,7 +915,7 @@ func diff[T comparable](old, new []T) (onlyOld, onlyNew, shared []T) {
return
}

func diffCadenceValues(old, new []interpreter.Value) (onlyOld, onlyNew, shared []interpreter.Value) {
func diffCadenceValues(oldInterpreter *interpreter.Interpreter, old, new []interpreter.Value) (onlyOld, onlyNew, shared []interpreter.Value) {
onlyOld = make([]interpreter.Value, 0, len(old))
onlyNew = make([]interpreter.Value, 0, len(new))
shared = make([]interpreter.Value, 0, min(len(old), len(new)))
Expand All @@ -929,7 +929,7 @@ func diffCadenceValues(old, new []interpreter.Value) (onlyOld, onlyNew, shared [
foundShared := false

if ev, ok := o.(interpreter.EquatableValue); ok {
if ev.Equal(nil, interpreter.EmptyLocationRange, n) {
if ev.Equal(oldInterpreter, interpreter.EmptyLocationRange, n) {
foundShared = true
}
} else {
Expand Down

0 comments on commit a8e97c1

Please sign in to comment.