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

fix: error message for invalid map types #708

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions src/types/__snapshots__/resolveDescriptors.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ 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
"<unknown>:4:19: Invalid map type. Check https://docs.tact-lang.org/book/maps#allowed-types
Line 4, col 19:
3 |
> 4 | const m: map<Int, String> = null;
Expand All @@ -497,7 +497,7 @@ Line 4, col 19:
`;

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
"<unknown>:6:23: Invalid map type. Check https://docs.tact-lang.org/book/maps#allowed-types
Line 6, col 23:
5 | contract Test {
> 6 | const m: map<Int, String> = null;
Expand All @@ -517,7 +517,7 @@ Line 6, col 34:
`;

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
"<unknown>:6:29: Invalid map type. Check https://docs.tact-lang.org/book/maps#allowed-types
Line 6, col 29:
5 | contract Test {
> 6 | get fun foo(): map<Int, String> {
Expand All @@ -527,7 +527,7 @@ Line 6, col 29:
`;

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
"<unknown>:4:16: Invalid map type. Check https://docs.tact-lang.org/book/maps#allowed-types
Line 4, col 16:
3 |
> 4 | fun foo(m: map<Bool, Int>) { }
Expand Down
2 changes: 1 addition & 1 deletion src/types/__snapshots__/resolveStatements.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ 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
"<unknown>:5:16: Invalid map type. Check https://docs.tact-lang.org/book/maps#allowed-types
Line 5, col 16:
4 | fun foo() {
> 5 | let m: map<String, Int> = null;
Expand Down
2 changes: 1 addition & 1 deletion src/types/resolveDescriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function verifyMapTypes(
): void {
if (!allowedTypeNames.includes(idText(typeId))) {
throwCompilationError(
"Invalid key type for map. Check https://docs.tact-lang.org/book/maps#allowed-types",
"Invalid map type. Check https://docs.tact-lang.org/book/maps#allowed-types",
typeId.loc,
);
}
Expand Down
Loading