tact-lang / tact

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

Typechecker misses name clashes between contract vars and consts inhereted from a trait #477

Closed anton-trunov closed 3 days ago

anton-trunov commented 4 days ago

The following contract should fail with a var-scope error:

contract Foo {
  storageReserve: Int;

  init() {
    self.storageReserve = ton("0.05");
  }
}

because storageReserve is a virtual constant defined in BaseTrait. So it should not be reassignable.

The intended meaning of the above contract is like so:

contract Foo {
  override const storageReserve: Int = ton("0.05");
  ...
}

(which is documented here: https://docs.tact-lang.org/ref/core-base#self-storagereserve)

Based on a report by @pantemon