Zilliqa / scilla

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

SanityChecker: Check that map value is unboxed before use #1146

Closed jubnzv closed 1 year ago

jubnzv commented 2 years ago

This PR adds an additional check for SanityChecker that warns about not matched values returned from map get operations.

Closes #1097

jubnzv commented 2 years ago

I have tested it on all contracts from the blockchain, and there are no false positives.

It will report on unused variables returned from the map get operation, but I prefer to leave these warnings to remind the user that they don't forget to match them later.

jubnzv commented 1 year ago

Are we not covering aliasing like in the following example?

Yes, this is the expected behavior.

v_opt_alias is matched, so we don't report it. But v_opt can still be used later. For example, if the user sends v_opt in the message/event below, it will be an error.