tact-lang / tact

Tact compiler main repository
https://tact-lang.org
MIT License
280 stars 56 forks source link

Error message with weird JS/TS type coersion upon compiling a contract with a missing storage field declaration #501

Closed novusnota closed 21 hours ago

novusnota commented 5 days ago

Consider the following snippet:

contract Example {
    init() {
        self.nonExistentField = 42;
    }
}

Its compilation fails (as expected), but produces a weird error involving type coersion of JS/TS somewhere (not expected):

Error: example.tact:3:9: Type "Example" does not have a field named "[object Object]"
Line 3, col 9:
  2 |     init() {
> 3 |         self.nonExistentField = 42;
              ^~~~~~~~~~~~~~~~~~~~~
  4 |     }

    at throwCompilationError (node_modules/@tact-lang/compiler/dist/errors.js:64:11)
    at resolveFieldAccess (node_modules/@tact-lang/compiler/dist/types/resolveExpression.js:252:48)
    at resolveExpression (node_modules/@tact-lang/compiler/dist/types/resolveExpression.js:487:16)
    at processStatements (node_modules/@tact-lang/compiler/dist/types/resolveStatements.js:153:61)
    at processFunctionBody (node_modules/@tact-lang/compiler/dist/types/resolveStatements.js:391:17)
    at resolveStatements (node_modules/@tact-lang/compiler/dist/types/resolveStatements.js:446:19)
    at precompile (node_modules/@tact-lang/compiler/dist/pipeline/precompile.js:24:53)
    at build (node_modules/@tact-lang/compiler/dist/pipeline/build.js:58:43)
    at Object.run (node_modules/@tact-lang/compiler/dist/node.js:84:47)
anton-trunov commented 5 days ago

Looks like #498 is related