contract C =
record state = {m : map(int, int)}
entrypoint init() = {m = {[1] = 2}}
stateful entrypoint foo(ix : int) =
let res = state.m[ix]
__foo(ix)
res
stateful entrypoint __foo(ix : int) =
put(state{ m = Map.delete(ix, state.m) })
The optimization phase will incorrectly push the Map.lookup (let res = state.m[ix]) past the call to __foo as is evident by the resulting FATE code:
...
FUNCTION foo( integer) : integer
;; BB : 0
PUSH arg0
CALL "IBB"
;; BB : 1
POP var9999
MAP_LOOKUP a store1 arg0
RETURN
This results in any call to foo failing since either ix is not there in the first place, or we delete it before looking at it - this is obviously a bug.
The following contract is incorrectly compiled:
The optimization phase will incorrectly push the
Map.lookup
(let res = state.m[ix]
) past the call to__foo
as is evident by the resulting FATE code:This results in any call to
foo
failing since eitherix
is not there in the first place, or we delete it before looking at it - this is obviously a bug.