Skip to content

Prevent optimisation of %Michelson lambdas

Tom Jack requested to merge intensional-michelson-bugfix into dev

This makes it so that e.g. Bytes.pack [%Michelson ({| { BLAH } |} : a -> b )] will compile exactly to LAMBDA a b { BLAH } ; PACK, BLAH will not be optimized.

This came up here when er433 documented what looks to me like a bug.

To me, the optimizer should not affect the semantics of Bytes.pack [%Michelson ...], and it should be possible to construct particular lambdas, to be packed, or transferred to other contracts, or whatever. So we should not optimize their bodies.

When a %Michelson lambda is used only in applications and is inlined, the inlined code will still be optimized.

In the end, this change might cause more annoyance than utility. I don't know. Maybe no one will notice either way.

Someday, I would rather add a separate intensional lambda type, distinct from the extensional function type. Then the extensional functions can always be optimized (no matter how they are defined,) while the intensional functions never will be. And it should be an error (or suppressible warning) to use an extensional function in an intensional way.

Merge request reports

Loading