Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add container static types #1125

Merged
merged 89 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
08acb93
add static type to array value
turbolent Jun 28, 2021
06adadc
add dictionary type to dictionary value
turbolent Jun 28, 2021
a2bbe8c
add types to external arrays and dictionaries
turbolent Jun 29, 2021
873aa0a
resolve TODOs
turbolent Jun 29, 2021
dce0364
Add encoder v5
SupunS Jun 30, 2021
1d223b4
Add decoder v5
SupunS Jun 30, 2021
25fcf27
Add encoding/decoding array static type info
SupunS Jun 29, 2021
379db97
Update array encoding tests
SupunS Jun 29, 2021
2b2c1ff
Split and refactor array head decoding
SupunS Jun 30, 2021
9b6ca95
Refactor decoder
SupunS Jun 30, 2021
0ee0c91
Add encoding/decoding array static type info
SupunS Jun 29, 2021
8b62e52
Split and refactor array head decoding
SupunS Jun 30, 2021
dc72ec5
Add encoding/decoding dictionary static type info
SupunS Jun 29, 2021
afe7ae8
Re-arrange encoding format to move types to the start
SupunS Jun 30, 2021
f00489b
Ignore metainfo decoding for older encoding versions
SupunS Jun 30, 2021
93b833a
Update version check in decoder
SupunS Jun 30, 2021
d0306c5
Merge branch 'supun/array-static-type' of https://github.com/onflow/c…
SupunS Jun 30, 2021
a2a1ea6
Update version check in decoder
SupunS Jun 30, 2021
882a2fd
Store staticType instead of semaType in array values
SupunS Jun 30, 2021
3859ea4
Store staticType instead of semaType in dictionary values
SupunS Jun 30, 2021
23a3cd4
Merge branch 'supun/store-static-type' into supun/array-static-type
SupunS Jun 30, 2021
2d8a104
Use concrete values for static tupes
SupunS Jun 30, 2021
aa03ad0
Merge branch 'supun/store-static-type' into supun/array-static-type
SupunS Jun 30, 2021
a1a3390
Store decoded static type in array value
SupunS Jun 30, 2021
e86ca0c
Merge branch 'supun/array-static-type' into supun/dictionary-static-type
SupunS Jun 30, 2021
a1e9d97
Store static type in dictionary value. Fix tests
SupunS Jun 30, 2021
ac3f838
Clean up
SupunS Jun 30, 2021
1a668ec
Merge pull request #1034 from onflow/bastian/array-static-type
turbolent Jun 30, 2021
0afd878
Merge pull request #1039 from onflow/supun/encoder-v5
turbolent Jun 30, 2021
e348776
Merge branch 'feature/container-static-types' into supun/store-static…
turbolent Jun 30, 2021
465b87b
Merge pull request #1041 from onflow/supun/store-static-type
turbolent Jun 30, 2021
f587ce5
Remove TODO
SupunS Jun 30, 2021
a8a063f
Remove obsolete todo
SupunS Jun 30, 2021
018bd22
fix tests
turbolent Jun 30, 2021
1f348e4
refactor
turbolent Jun 30, 2021
567d20e
remove delegation to previous decoder
turbolent Jun 30, 2021
342c8c0
Merge branch 'feature/container-static-types' into supun/array-static…
turbolent Jun 30, 2021
da6b124
Merge pull request #1035 from onflow/supun/array-static-type
turbolent Jun 30, 2021
4d183e1
Merge branch 'feature/container-static-types' into supun/dictionary-s…
turbolent Jun 30, 2021
f913717
remove delegation to previous decoder
turbolent Jun 30, 2021
c3e391f
Merge pull request #1036 from onflow/supun/dictionary-static-type
turbolent Jun 30, 2021
0a5dbb7
remove old tests
turbolent Jun 30, 2021
ec6caec
fix encoding of deferred arrays
turbolent Jun 30, 2021
24a9310
remove old v3 decoder
turbolent Jun 30, 2021
5d5eb76
remove dead code
turbolent Jun 30, 2021
342fd28
Revert "remove delegation to previous decoder"
turbolent Jun 30, 2021
ee11125
Revert "remove delegation to previous decoder"
turbolent Jun 30, 2021
af001b8
add version to field keys, comment constant to please linter
turbolent Jun 30, 2021
c171f5f
cleanup
turbolent Jun 30, 2021
66fc4e9
infer array and dictionary static types from expected type during import
turbolent Jun 30, 2021
46371b7
consider static types of arrays and dictionaries in equality tests
turbolent Jun 30, 2021
37257d3
include static types in dynamic types for arrays and dictionaries
turbolent Jun 30, 2021
b88f083
consider container's static type in dynamic type check
turbolent Jun 30, 2021
28d2173
Add version check for decoding dictionary meta info. Add tests.
SupunS Jul 2, 2021
f8f09b6
Merge pull request #1042 from onflow/bastian/finish-storage-v5
SupunS Jul 2, 2021
b561c08
Merge pull request #1038 from onflow/bastian/container-value-import-t…
SupunS Jul 2, 2021
3cfe0f1
Merge pull request #1043 from onflow/bastian/static-types-in-dynamic-…
SupunS Jul 2, 2021
1503e7e
Add imported array/dictionary value type conformance tests
SupunS Jul 2, 2021
d18d091
Add tests for decoding from old format and encoding in new format
SupunS Jul 2, 2021
b33473b
Add static type check for imported values
SupunS Jul 5, 2021
8ec25b6
Merge pull request #1045 from onflow/supun/dynamic-type-conformance
SupunS Jul 5, 2021
f2861e5
Merge pull request #1046 from onflow/supun/encode-decode
SupunS Jul 5, 2021
9312f2f
Merge pull request #1048 from onflow/supun/ensure-type
SupunS Jul 5, 2021
cee6c4f
Infer static-type from imported array/dictionary values
SupunS Jul 6, 2021
2ea91d6
Add tests for inferring static type from imported arrays/dictionaries
SupunS Jul 5, 2021
b407b3b
Refactor and cleanup
SupunS Jul 6, 2021
d76e683
add ElementType function to ArrayStaticType
turbolent Jul 6, 2021
0d4c18c
remove obsolete fields
turbolent Jul 6, 2021
2e2120a
Merge pull request #1053 from onflow/bastian/remove-obsolete-fields
turbolent Jul 7, 2021
6ae77be
return a dedicated error when decoding fails due to an unsupported CB…
turbolent Jul 12, 2021
7df3b4f
Merge pull request #1064 from onflow/bastian/decoding-error
turbolent Jul 13, 2021
20560c0
Add container mutation check for arrays and dictionaries
SupunS Aug 3, 2021
3e2e678
Add tests for array/dictionary runtime mutation check
SupunS Aug 3, 2021
6bb1844
Merge commit 'refs/pull/1052/head' of https://github.com/onflow/caden…
SupunS Aug 3, 2021
9b085dc
Fix failing tests. Add more tests
SupunS Aug 4, 2021
1524105
Add tests for mutation through references
SupunS Aug 4, 2021
3290e15
Pass interpreter for dictionary new function
SupunS Aug 4, 2021
fcfa2b7
Refactore code
SupunS Aug 4, 2021
d7ed020
Merge branch 'master' of https://github.com/onflow/cadence into supun…
SupunS Aug 11, 2021
9e01d03
Fix linter error
SupunS Aug 11, 2021
1c28cca
Merge pull request #1107 from onflow/supun/container-static-types-sync
SupunS Aug 12, 2021
798664b
Merge branch 'feature/container-static-types' of https://github.com/o…
SupunS Aug 13, 2021
6d7e59d
Add code comments
SupunS Aug 24, 2021
943dd48
Merge pull request #1052 from onflow/supun/infer-static-type-2
SupunS Aug 24, 2021
2682dc6
Merge branch 'feature/container-static-types' of https://github.com/o…
SupunS Aug 24, 2021
4af18e7
Move 'checkContainerMutation' function to the interpreter
SupunS Aug 24, 2021
fa2488a
Merge pull request #1103 from onflow/supun/container-static-types
SupunS Aug 24, 2021
412b5f7
Merge branch 'master' of https://github.com/onflow/cadence into supun…
SupunS Aug 24, 2021
5b2c6ce
Resolve TODOs related to static types for deferred values
SupunS Aug 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions runtime/interpreter/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ type DecoderV5 struct {
// maxInt is math.MaxInt32 or math.MaxInt64 depending on arch.
const maxInt = 1<<(bits.UintSize-1) - 1

type UnsupportedTagDecodingError struct {
Path []string
Tag uint64
}

func (e UnsupportedTagDecodingError) Error() string {
return fmt.Sprintf(
"unsupported decoded tag (@ %s): %d",
strings.Join(e.Path, "."),
e.Tag,
)
}

// DecodeValue returns a value decoded from its CBOR-encoded representation,
// for the given owner (can be `nil`). It can decode storage format
// version 4 and later.
Expand Down Expand Up @@ -290,11 +303,10 @@ func (d *DecoderV5) decodeValue(path []string) (Value, error) {
value, err = d.decodeType()

default:
return nil, fmt.Errorf(
"unsupported decoded tag (@ %s): %d",
strings.Join(path, "."),
num,
)
return nil, UnsupportedTagDecodingError{
Path: path[:],
Tag: num,
}
}

default:
Expand Down
9 changes: 4 additions & 5 deletions runtime/interpreter/decode_v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,10 @@ func (d *DecoderV4) decodeValue(path []string) (Value, error) {
value, err = d.decodeType()

default:
return nil, fmt.Errorf(
"unsupported decoded tag (@ %s): %d",
strings.Join(path, "."),
num,
)
return nil, UnsupportedTagDecodingError{
Path: path[:],
Tag: num,
}
}

default:
Expand Down