diff options
author | simonpj@microsoft.com <unknown> | 2006-08-18 11:07:02 +0000 |
---|---|---|
committer | simonpj@microsoft.com <unknown> | 2006-08-18 11:07:02 +0000 |
commit | 7a59afcebe45ea87c42006873f77eb4600d7316f (patch) | |
tree | fe27fea4d895efc598f0f43e3625cd839ebc15b9 /compiler/deSugar/Match.lhs | |
parent | d5c6d00221c1398732b45991ecbb1ab0c08cc977 (diff) | |
download | haskell-7a59afcebe45ea87c42006873f77eb4600d7316f.tar.gz |
Fall over more gracefully when there's a Template Haskell error
For a long time, Template Haskell has fallen over in a very un-graceful
way (i.e. panic) even when it encounters a programmer error. In particular,
when DsMeta converts HsSyn to TH syntax, it may find Haskell code that
TH does not understand. This should be reported as a normal programmer
error, not with a compiler panic!
Originally the desugarer was supposed to never generate error
messages, but this TH desugaring thing does make it do so. And in
fact, for other reasons, the desugarer now uses the TcRnIf monad, the
common monad used by the renamer, typechecker, interface checker, and
desugarer.
This patch completes the job, by
- allowing the desugarer to generate errors
- re-plumbing the error handling to take account of this
- making DsMeta use the new facilities to report error gracefully
Quite a few lines of code are touched, but nothing deep is going on.
Fixes Trac# 760.
Diffstat (limited to 'compiler/deSugar/Match.lhs')
-rw-r--r-- | compiler/deSugar/Match.lhs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/deSugar/Match.lhs b/compiler/deSugar/Match.lhs index d72d6adf17..b428658dca 100644 --- a/compiler/deSugar/Match.lhs +++ b/compiler/deSugar/Match.lhs @@ -91,7 +91,7 @@ The next two functions create the warning message. \begin{code} dsShadowWarn :: DsMatchContext -> [EquationInfo] -> DsM () dsShadowWarn ctx@(DsMatchContext kind loc) qs - = putSrcSpanDs loc (dsWarn warn) + = putSrcSpanDs loc (warnDs warn) where warn | qs `lengthExceeds` maximum_output = pp_context ctx (ptext SLIT("are overlapped")) @@ -104,7 +104,7 @@ dsShadowWarn ctx@(DsMatchContext kind loc) qs dsIncompleteWarn :: DsMatchContext -> [ExhaustivePat] -> DsM () dsIncompleteWarn ctx@(DsMatchContext kind loc) pats - = putSrcSpanDs loc (dsWarn warn) + = putSrcSpanDs loc (warnDs warn) where warn = pp_context ctx (ptext SLIT("are non-exhaustive")) (\f -> hang (ptext SLIT("Patterns not matched:")) |