Skip to content

using x as a field name causes an compilation error #296

@Y-Nak

Description

@Y-Nak

When x is used in the contract field, the compiler emits an error.

PoC

Code:

import std;

contract PoC {
    x : word;
}

Error:

tcExp not implemented for: this.x
FieldAccess Nothing x
 - in:Typedef.rep(this.x)
 - in:function toWord (x : ?$5999) -> word {
   return Typedef.rep(this.x);
}
 - in:?$5999 : Add, ?$5999 : Sub, ?$5999 : Bounded, ?$5999 : Eq, ?$5999 : Ord, ?$5999 : Typedef (word) => default instance ?$5999 : Num {
   function maxVal () -> ?$5999 {
      return Bounded.maxVal();
   }
   function toWord (x : ?$5999) -> word {
      return Typedef.rep(this.x);
   }
   function fromWord (x : word) -> ?$5999 {
      return Typedef.abs(this.x);
   }
   function add (x : ?$5999, y : ?$5999) -> ?$5999 {
      return Add.add(this.x, y);
   }
   function sub (x : ?$5999, y : ?$5999) -> ?$5999 {
      return Sub.sub(this.x, y);
   }
   function gt (x : ?$5999, y : ?$5999) -> bool {
      return Ord.gt(this.x, y);
   }
}

If x is renamed to x1, for example, the compilation succeeds.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions