Skip to content

Commit

Permalink
test of a fix
Browse files Browse the repository at this point in the history
  • Loading branch information
janezpodhostnik authored and turbolent committed Nov 25, 2020
1 parent db5af95 commit e027ad0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions runtime/interpreter/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,29 @@ func (d *Decoder) decodeLocationAndTypeID(
}
typeID := sema.TypeID(encodedTypeID)

// Special case: The decoded location is an address location without name.
//
// In the first version of the storage format, accounts could only store one contract
// instead of several contracts (separated by name), so composite's locations were
// address locations without a name, i.e. just the bare address.
//
// An update added support for multiple contracts per account, which added names to address locations:
// Each contract of an account is stored in a distinct location.
//
// So to keep backwards-compatibility:
// If the location is an address location without a name,
// then infer the name from the type ID.

if addressLocation, ok := location.(ast.AddressLocation); ok && addressLocation.Name == "" {
qualifiedIdentifier := location.QualifiedIdentifier(typeID)
parts := strings.SplitN(qualifiedIdentifier, ".", 2)

location = ast.AddressLocation{
Address: addressLocation.Address,
Name: parts[0],
}
}

return location, typeID, nil
}

Expand Down

0 comments on commit e027ad0

Please sign in to comment.