Commit 96daafc3 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Attach the right location to pattern synonym error message (fixes Trac #8841)

parent 4b355cd2
......@@ -186,7 +186,7 @@ tcPatSynWrapper lname lpat dir args univ_tvs ex_tvs theta pat_ty
(Unidirectional, _) ->
return Nothing
(ImplicitBidirectional, Nothing) ->
cannotInvertPatSynErr (unLoc lpat)
cannotInvertPatSynErr lpat
(ImplicitBidirectional, Just lexpr) ->
fmap Just $ tc_pat_syn_wrapper_from_expr lname lexpr args univ_tvs ex_tvs theta pat_ty }
......@@ -281,10 +281,9 @@ asPatInPatSynErr pat
hang (ptext (sLit "Pattern synonym definition cannot contain as-patterns (@):"))
2 (ppr pat)
-- TODO: Highlight sub-pattern that causes the problem
cannotInvertPatSynErr :: OutputableBndr name => Pat name -> TcM a
cannotInvertPatSynErr pat
= failWithTc $
cannotInvertPatSynErr :: OutputableBndr name => LPat name -> TcM a
cannotInvertPatSynErr (L loc pat)
= setSrcSpan loc $ failWithTc $
hang (ptext (sLit "Right-hand side of bidirectional pattern synonym cannot be used as an expression"))
2 (ppr pat)
......
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