From dc6e62d1052fab2f42b32a60fedc417db74d36c0 Mon Sep 17 00:00:00 2001 From: Gusarich Date: Tue, 11 Jun 2024 23:59:04 +0300 Subject: [PATCH] fix lvalue path limitation --- .../resolveDescriptors.spec.ts.snap | 10 +++++++ src/types/resolveDescriptors.ts | 6 +++- ...ract-duplicate-const-string-receiver5.tact | 28 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/types/test-failed/contract-duplicate-const-string-receiver5.tact diff --git a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap index 8de114d47..74f26fdca 100644 --- a/src/types/__snapshots__/resolveDescriptors.spec.ts.snap +++ b/src/types/__snapshots__/resolveDescriptors.spec.ts.snap @@ -90,6 +90,16 @@ Line 15, col 5: " `; +exports[`resolveDescriptors should fail descriptors for contract-duplicate-const-string-receiver5 1`] = ` +":25:5: Invalid comment receiver selector +Line 25, col 5: + 24 | +> 25 | receive(self.struct.s) { + ^~~~~~~~~~~~~~~~~~~~~~~~ + 26 | +" +`; + exports[`resolveDescriptors should fail descriptors for contract-duplicate-external-fallback-receiver 1`] = ` ":20:5: Empty receive function already exists Line 20, col 5: diff --git a/src/types/resolveDescriptors.ts b/src/types/resolveDescriptors.ts index 344250532..1af3b084f 100644 --- a/src/types/resolveDescriptors.ts +++ b/src/types/resolveDescriptors.ts @@ -1033,7 +1033,11 @@ export function resolveDescriptors(ctx: CompilerContext) { const internal = d.selector.kind === "internal-const-comment"; - if (d.selector.comment.length > 2) { + if ( + d.selector.comment.length > 2 || + (d.selector.comment.length == 2 && + d.selector.comment[0].name !== "self") + ) { // TEMPORARY // to be reworked after #284 and #400 are resolved throwSyntaxError( diff --git a/src/types/test-failed/contract-duplicate-const-string-receiver5.tact b/src/types/test-failed/contract-duplicate-const-string-receiver5.tact new file mode 100644 index 000000000..dd4ead50c --- /dev/null +++ b/src/types/test-failed/contract-duplicate-const-string-receiver5.tact @@ -0,0 +1,28 @@ +primitive Int; +primitive String; + +trait BaseTrait { + +} + +struct MyStruct { + s: String; +} + +contract Main { + struct: MyStruct; + + init () { + self.struct = MyStruct { + s: "string 1" + }; + } + + receive("string 1") { + + } + + receive(self.struct.s) { + + } +} \ No newline at end of file