-
Notifications
You must be signed in to change notification settings - Fork 482
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
More reliable short-cicruiting behavior for ||
and &&
operators.
#5863
Conversation
13d5855
to
96920bf
Compare
96920bf
to
65b2d8f
Compare
65b2d8f
to
3d3c478
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like special-casing certain functions in the compiler. But I think I am outvoted on this 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Unisay A few more comments.
PlutusTx.Bool.&&
and ||
should now be marked NOINLINE
, since we don't need their unfoldings.
I don't really like special-casing certain functions in the compiler.
@michaelpj Yeah but if anything should be special-cased, it's &&
and ||
, since they are special in almost all other strict languages.
There's a Note [Short-circuit evaluation for && and ||] which is now out of date. The Note should be rewritten to explain that saturated applications of |
I wonder if we should raise an error if |
…ntersectMBO#5863) * chore: fix hlint warnings * Test case that demonstrates lack of short-curicuiting under no GHC optimisations. * Compile (&&), (||) as if .. then .. else * Changelog entry * Comment about Short-curcuiting && || tests
Before the fix:
After the fix:
The fix is implemented as a code rewrite when compiling an expression:
a && b
is rewritten asif a then b else False
a || b
is rewritten asif a then True else b
Based on this un-merged PR.
Closes #4114