-
Notifications
You must be signed in to change notification settings - Fork 572
Labels
Description
Description
This is a regression apparently introduced in #4293.
A case statement containing guard clauses with pattern guards which bind the same variable result in an error when building with 0.15.3 but not 1887bcf (just before that PR was merged).
To Reproduce
data Foo = Foo Int | Bar Int
g :: Foo -> Int
g =
case _ of
a
| Bar z <- a
-> z
| Foo z <- a
-> z
| otherwise
-> 42
Results in the following error:
Error found:
in module Main
at src/Main.purs:15:12 - 15:13 (line 15, column 12 - line 15, column 13)
Value z is undefined.
while inferring the type of z
in value declaration g
After renaming the z
in the 1st guard clause, the error disappears.
Expected behavior
No error - as in previous compiler versions.
Variables bound in guard clauses are only in scope in the corresponding expression, and there is no conflict between different guard clauses.
Additional context
Add any other context about the problem here.
PureScript version
0.15.3