Indigo compiler crashes with new Lorentz (#)
Clarification and motivation
morley!1314 (merged) has some unfortunate ramifications in Indigo.
In Indigo, we depend on the fact that Lorentz just ignored anything after failing instructions, but this is no longer the case. The net result is we get errors on compiling some Indigo contracts.
The particular failure points are things like
varActionGet _ FailureStack = error "You try to get a cell on failure stack"
which then get forced during compilation when Lorentz tries to filter out non-doc instructions after failWith
.
For now, I just reverted the operator in Indigo to the old behaviour to make things work in !52 (merged), but in principle we should probably do something about this.
Note that Indigo's tests don't test for this particular case, I've run into it while updating morley-ledgers. The particular failing code snippet is
newBalance <- ifSome (isNat $ oldBalance - val)
return (failNotEnoughBalance @Natural oldBalance)
setStorageField @Storage #sLedger $ ledger_ !: (from, nonZero newBalance)
where
failNotEnoughBalance :: forall r ex. (ex :~> Natural, ReturnableValue r) => ex -> IndigoM (RetVars r)
failNotEnoughBalance curBalance = failCustom @r #notEnoughBalance $ pair
(val !~ #required)
(curBalance !~ #present)
but there are other similar cases. The general pattern is "conditional failure, then some Indigo instructions after".
Acceptance criteria
- How we're going to fix this is discussed
- Indigo contracts don't crash with new Lorentz