Typechecker hangs for a pattern guard
Summary
The type checker hangs for an (incorrect) pattern guard.
Steps to reproduce
module PatMatch where
data M a b c = MkM1 a b c
ffff :: M a b c -> IO ()
ffff x = do { let localdef x | MkM1 a <- x
= return ()
| otherwise
= return ()
; localdef x
}
$ ghc PatMatch.hs
Expected behavior
The type checker should fail with an error message that says in the pattern guard MkM1 a <- x
MkM1 is applied to to few arguments. It instead just hangs with
$ ghc PatMatch.hs
[1 of 1] Compiling PatMatch ( PatMatch.hs, PatMatch.o ) [Source file changed]
PatMatch.hs:7:32: error:
Works as expected in ghc-9.2.8
PatMatch.hs:7:32: error:
• The constructor ‘MkM1’ should have 3 arguments, but has been given 1
• In the pattern: MkM1 a
In a stmt of a pattern guard for
an equation for ‘localdef’:
MkM1 a <- x
In an equation for ‘localdef’:
localdef x
| MkM1 a <- x = return ()
| otherwise = return ()
|
7 | ffff x = do { let localdef x | MkM1 a <- x
| ^^^^^^
Environment
- GHC version used: ghc-9.4.4
Optional:
- Operating System: MacOs Ventura 13.4
- System Architecture: x86