Skip to content

Fix: suppress "Use guards" under RebindableSyntax (fixes #1559)#1688

Open
mgajda wants to merge 1 commit into
ndmitchell:masterfrom
mgajda:fix/guards-rebindable-syntax
Open

Fix: suppress "Use guards" under RebindableSyntax (fixes #1559)#1688
mgajda wants to merge 1 commit into
ndmitchell:masterfrom
mgajda:fix/guards-rebindable-syntax

Conversation

@mgajda
Copy link
Copy Markdown

@mgajda mgajda commented Apr 19, 2026

Summary

Fixes #1559. With RebindableSyntax, if-then-else desugars via the
user's ifThenElse, which may accept non-Bool conditions. Pattern
guards, however, always require Bool, so rewriting if a then x else if b then y else z into the guards form changes semantics and can break
compilation — as reproduced in the original issue.

The fix threads a rebindableSyntax flag through patternHint and skips
the "Use guards" branch when the extension is enabled. The other
Pattern hints (Redundant guard, Redundant where, Use otherwise)
are unaffected.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't suggest replacing if … else if … else with guards when RebindableSyntax is enabled

1 participant