Fix: suppress "Use guards" under RebindableSyntax (fixes #1559)#1688
Open
mgajda wants to merge 1 commit into
Open
Fix: suppress "Use guards" under RebindableSyntax (fixes #1559)#1688mgajda wants to merge 1 commit into
mgajda wants to merge 1 commit into
Conversation
…ell#1559) When `RebindableSyntax` is on, `if-then-else` desugars through the user-defined `ifThenElse` and may accept non-`Bool` conditions, while pattern guards always require `Bool`. Rewriting a chain of `if` into guards therefore changes semantics and can break compilation. Thread a `rebindableSyntax` flag through `patternHint` / `hints` and skip the `"Use guards"` branch when the extension is in scope.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1559. With
RebindableSyntax,if-then-elsedesugars via theuser's
ifThenElse, which may accept non-Boolconditions. Patternguards, however, always require
Bool, so rewritingif a then x else if b then y else zinto the guards form changes semantics and can breakcompilation — as reproduced in the original issue.
The fix threads a
rebindableSyntaxflag throughpatternHintand skipsthe
"Use guards"branch when the extension is enabled. The otherPatternhints (Redundant guard,Redundant where,Use otherwise)are unaffected.