Commit 594aa496 authored by simonpj@microsoft.com's avatar simonpj@microsoft.com
Browse files

Improve error report for pattern guards

parent 5d3051c6
...@@ -604,11 +604,12 @@ rnGRHS ctxt = wrapLocFstM (rnGRHS' ctxt) ...@@ -604,11 +604,12 @@ rnGRHS ctxt = wrapLocFstM (rnGRHS' ctxt)
rnGRHS' ctxt (GRHS guards rhs) rnGRHS' ctxt (GRHS guards rhs)
= do { opt_GlasgowExts <- doptM Opt_GlasgowExts = do { opt_GlasgowExts <- doptM Opt_GlasgowExts
; checkM (opt_GlasgowExts || is_standard_guard guards)
(addWarn (nonStdGuardErr guards))
; ((guards', rhs'), fvs) <- rnStmts (PatGuard ctxt) guards $ ; ((guards', rhs'), fvs) <- rnStmts (PatGuard ctxt) guards $
rnLExpr rhs rnLExpr rhs
; checkM (opt_GlasgowExts || is_standard_guard guards')
(addWarn (nonStdGuardErr guards'))
; return (GRHS guards' rhs', fvs) } ; return (GRHS guards' rhs', fvs) }
where where
-- Standard Haskell 1.4 guards are just a single boolean -- Standard Haskell 1.4 guards are just a single boolean
...@@ -654,8 +655,7 @@ bindsInHsBootFile mbinds ...@@ -654,8 +655,7 @@ bindsInHsBootFile mbinds
= hang (ptext SLIT("Bindings in hs-boot files are not allowed")) = hang (ptext SLIT("Bindings in hs-boot files are not allowed"))
2 (ppr mbinds) 2 (ppr mbinds)
nonStdGuardErr guard nonStdGuardErr guards
= hang (ptext = hang (ptext SLIT("accepting non-standard pattern guards (-fglasgow-exts to suppress this message)"))
SLIT("accepting non-standard pattern guards (-fglasgow-exts to suppress this message)") 4 (interpp'SP guards)
) 4 (ppr guard)
\end{code} \end{code}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment