-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplification pass assumes laziness, resulting in miscompilation #4826
Comments
Sorry, can you be more specific? Is this a PIR program? A Haskell program? Unfortunately we can't stop GHC from touching the program entirely, so if this is Haskell it may indeed be something that GHC is doing. |
I've posted a link to a fork in the summary where I've added goldens for the test. |
That's helpful, thanks. |
This was brought into the sprint, but hasn't been worked on yet. Chances are, it'll take a bit more time for us to get to this issue, I will keep you updated. |
PR #5280 shows that with the noinline pragma the evaluation results for the two examples are now the same. I.e., it IS GHC's inliner that causes the inconsistency. For now, users will have to turn off the GHC inliner by hand with the noinline pragma for affected functions. For example: trueOrError :: CompiledCode Bool
trueOrError = $$(compile [|| c True (P.error () :: Bool) ||])
where
{-# NOINLINE c #-}
c x _ = x The team will be discussing and exploring better solutions. We welcome your input as well. |
|
@zliu41 should we keep this issue open or advertise using |
Let's keep it open until we merge #5292 and start telling people to use |
Right. The internal ticket tracking this is PLT-5830. |
It's merged now (has been for a while) and hence we can close this issue with the following general advice: use |
Summary
While UPLC/PLC/PIR are strict, a simplification pass assumes the code is to be interpreted lazily, thus resulting in the following behaviour:
let c x _ = x in c True (error ())
will not err. If you however set it toconst
, it will err, because it's not simplified (for some arcane reason).Concrete example in fork of Plutus: https://github.com/mlabs-haskell/plutus/commits/las/miscompilation
Do you have a proposed solution for this issue?
It's not clear to me whether it's GHC doing this or a Plutus library. In the former case, disable the optimisation pass, however this would lead to decreased efficiency, in the latter case, keep track of whether it's possible for the term to err.
System info
No response
The text was updated successfully, but these errors were encountered: