tact-lang / tact

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

Abstract getters are allowed but cannot be used #490

Closed byakuren-hijiri closed 1 day ago

byakuren-hijiri commented 2 days ago

The typechecker allows to define the following function within a trait:

trait t {
  abstract get fun _k(): Int;
}

The problem is that it cannot be used in the contract inheriting the trait:

contract TestContract with t {
  override get fun _k(): Int {
    return 0;
  }
}

Error: contract.tact:8:3: Overridden function "_k" can not be a getter

Without override:

contract TestContract with t {
  get fun _k(): Int {
    return 0;
  }
}

Error: contract.tact:7:1: Function "_k" already exist in "TestContract"

My suggestion is to either allow to override abstract getters in contracts, or to forbid their definitions in traits in the typechecker.