Proto/Michelson: improve the trace for unpackable types
What
Slightly improve error reporting when a value is used in a context where it is expected to be packable (i.e. encoded to be emitted, used as failwith parameter, etc).
Why
This can improve some error messages
How
In script_ir_translator.check_packable, simply add another error to state the function failed due to not being packable.
The backport for proto T will be done in a follow-up MR.
Manually testing the MR
Run a sandbox, and try to originate the following contract:
parameter address;
storage (big_map address nat);
code {
CDR ;
PUSH nat 0 ;
PUSH nat 0 ;
COMPARE ;
EQ ;
IF
{
}
{
FAILWITH
};
DROP ;
NIL operation ;
PAIR
};
Without the new error, it fails with
Ill typed contract:
01: { parameter address ;
02: storage (big_map address nat) ;
03: code { CDR ;
04: PUSH nat 0 ;
05: PUSH nat 0 ;
06: COMPARE ;
07: EQ ;
08: IF {} { FAILWITH } ;
09: DROP ;
10: NIL operation ;
11: PAIR } }
At line 8 characters 17 to 25,
big_map or sapling_state type not expected here
With the new error:
Ill typed contract:
01: { parameter address ;
02: storage (big_map address nat) ;
03: code { CDR ;
04: PUSH nat 0 ;
05: PUSH nat 0 ;
06: COMPARE ;
07: EQ ;
08: IF {} { FAILWITH } ;
09: DROP ;
10: NIL operation ;
11: PAIR } }
At line 8 characters 17 to 25,
Value has a type that cannot be packed
At line 8 characters 17 to 25,
big_map or sapling_state type not expected here
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR