tact-lang / tact

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

Incorrect error message for non-initialized contract constants #332

Closed byakuren-hijiri closed 3 months ago

byakuren-hijiri commented 4 months ago
contract SampleTactContract with Deployable {
    const u4: Int;
}

Error message:

Tact compilation failed
contract.tact:8:5: Abstract function doesn't have abstract modifier
Line 8, col 5:
  7 | contract SampleTactContract with Deployable {
> 8 |     const u4: Int;
          ^~~~~~~~~~~~~~
  9 |   }

Expected: Something like this, e.g. Contract constant is not initialized.


When adding such a constant in the ASTContract entry directly, compilation fails with an exception here, because s is undefined.

anton-trunov commented 4 months ago

Constant declarations should be forbidden for contracts and only allowed for traits

byakuren-hijiri commented 3 months ago

The issue is still present in ac5b87abcaa13183a3fea0a499100b2bff8efdcc for non-initialized trait constants:

trait bYO___ZJ__g_g {
    const x_B_y_H_8: Int;
}

Compilation error:

Error: ../TON-Projects/tact-template/sources/contract.tact:4:5: Abstract function doesn't have abstract modifier
Line 4, col 5:
  3 | trait bYO___ZJ__g_g {
> 4 |     const x_B_y_H_8: Int;
          ^~~~~~~~~~~~~~~~~~~~~
  5 | }

It is just about an incorrect error message which has a trivial fix.