Skip to content

Disallow complex expressions on left-hand-sides of assignments. #13147

Open
@ekpyron

Description

@ekpyron

#13139 attempted to add some warnings about easy-to-miss dangling reference cases.

We could go beyond that and also warn about cases like this:

contract C {
   uint[] x;
   uint[] y;
   function g() internal returns (uint[] storage) {
      x.pop();
      return y;
   }
   function f() public {
      (x[x.length - 1], g()[1]) = (1, 2);
   }
}

(which, roughly, we got reported as a bug bounty report)

In general we could warn about using most kinds of complex expressions on left-hand-sides of tuple assignments, especially about function calls.

We should also check if we can construct problematic cases in non-tuple assignments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking change ⚠️low impactChanges are not very noticeable or potential benefits are limited.medium effortDefault level of effortmust have eventuallySomething we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.needs designThe proposal is too vague to be implemented right away

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions