Skip to content

Commit

Permalink
fix(typechecker): verify map type is well-formed
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-trunov committed Aug 17, 2024
1 parent 2b29403 commit f85c75f
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 93 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Returning `self` from getters is now allowed: PR [#666](https://github.com/tact-lang/tact/pull/666)
- Remainder fields in the middle of a struct are now forbidden: PR [#697](https://github.com/tact-lang/tact/pull/697)
- Defining two native functions from the same FunC function now does not fail compilation: PR [#699](https://github.com/tact-lang/tact/pull/699)
- Map types are checked for well-formedness in all type ascriptions: PR [#704](https://github.com/tact-lang/tact/pull/704)

## [1.4.3] - 2024-08-16

Expand Down
50 changes: 50 additions & 0 deletions src/types/__snapshots__/resolveDescriptors.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,56 @@ Line 7, col 1:
"
`;
exports[`resolveDescriptors should fail descriptors for wf-type-const 1`] = `
"<unknown>:4:19: Invalid key type for map. Check https://docs.tact-lang.org/book/maps#allowed-types
Line 4, col 19:
3 |
> 4 | const m: map<Int, String> = null;
^~~~~~
5 |
"
`;
exports[`resolveDescriptors should fail descriptors for wf-type-contract-const 1`] = `
"<unknown>:6:23: Invalid key type for map. Check https://docs.tact-lang.org/book/maps#allowed-types
Line 6, col 23:
5 | contract Test {
> 6 | const m: map<Int, String> = null;
^~~~~~
7 | }
"
`;
exports[`resolveDescriptors should fail descriptors for wf-type-contract-const-incorrect-annotation 1`] = `
"<unknown>:6:34: "Address" type cannot have as-annotation
Line 6, col 34:
5 | contract Test {
> 6 | const m: map<Int, Address as uint32> = null;
^~~~~~
7 | }
"
`;
exports[`resolveDescriptors should fail descriptors for wf-type-contract-getter 1`] = `
"<unknown>:6:29: Invalid key type for map. Check https://docs.tact-lang.org/book/maps#allowed-types
Line 6, col 29:
5 | contract Test {
> 6 | get fun foo(): map<Int, String> {
^~~~~~
7 | let m: map<Int, String> = null;
"
`;
exports[`resolveDescriptors should fail descriptors for wf-type-fun-param 1`] = `
"<unknown>:4:16: Invalid key type for map. Check https://docs.tact-lang.org/book/maps#allowed-types
Line 4, col 16:
3 |
> 4 | fun foo(m: map<Bool, Int>) { }
^~~~
5 |
"
`;
exports[`resolveDescriptors should resolve descriptors for const-decl-struct-with-default-field 1`] = `
{
"BaseTrait": {
Expand Down
10 changes: 10 additions & 0 deletions src/types/__snapshots__/resolveStatements.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,16 @@ Line 9, col 12:
"
`;
exports[`resolveStatements should fail statements for wf-type-let 1`] = `
"<unknown>:5:16: Invalid key type for map. Check https://docs.tact-lang.org/book/maps#allowed-types
Line 5, col 16:
4 | fun foo() {
> 5 | let m: map<String, Int> = null;
^~~~~~
6 | }
"
`;
exports[`resolveStatements should resolve statements for assign-self-mutating-method 1`] = `
[
[
Expand Down
Loading

0 comments on commit f85c75f

Please sign in to comment.