Skip to content

Short-circuit semantics of boolean operators #2

@bitbart

Description

@bitbart

Modify the semantics of TinySol so that the evaluation of boolean operators is short-circuited:

https://docs.soliditylang.org/en/latest/types.html#booleans

For example, in the following contract:

contract C {  
      uint x;
      function f() public { if (x==1 || this.g()==1) x+=1; else x=5; }
      function g() public view returns(uint) { require(x==0); return 1; } 
 }

executing two successive calls to the function f should yield x==2, since in the second transaction the first condition x==1 is true, and so there is no need to perform the call to g.

Similarly, in the contract:

contract C {  
      uint x;
      function f() public { if (x==0 && this.g()==1) x=1; else x=5; }
      function g() public view returns(uint) { require(x==0); return 1; }
}

executing two successive calls to f should yield x==5, since in the second transaction the first condition x==0 is false, and so there is no need to perform the call to g.

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