Zilliqa / scilla

Scilla - A Smart Contract Intermediate Level Language
https://scilla-lang.org
GNU General Public License v3.0
240 stars 78 forks source link

Check that map value is pattern-matched on after read #1097

Closed anton-trunov closed 2 years ago

anton-trunov commented 2 years ago

A real-world contract has code like this:

val <- map[key];
hash = builtin sha256hash val;
...

Perhaps the author intended to process val differently if it's a missing value (None). To prevent things like this we can analyse if val is actually pattern-matched on somewhere.

Another instance:

val <- map[key];

e = {
    _eventname : "EventName";
    val: val
};
event e

The programmer here did not mean to send an event containing an optional value.