Skip to content

Typechecker: state variables declared as constant #8

@bitbart

Description

@bitbart

Extend the typechecker so that it detects when a state variable declared as constant may be assigned somewhere in the contract other than in its declaration. For example, the contract:

contract C {
    int constant N=1;
    constructor() { N=2; } 
    function f(int n) external { }
  }

should not pass typechecking, because N is assigned in the constructor.

Additionally, check that constants are always initialized. For example, the contract:

contract C {
    int constant N;
    constructor() { } 
    function f(int n) external { }
  }

should not pass type checking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions