diff options
author | Eric Seidel <gridaphobe@gmail.com> | 2015-09-02 10:22:01 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-09-02 13:21:43 +0200 |
commit | 6740d70d95cb81cea3859ff847afc61ec439db4f (patch) | |
tree | 08199080ae5e55aafa1ff05cffd929039d3345bf /compiler/typecheck/TcBinds.hs | |
parent | ad26c54b86a868567d324d5de6fd0b4c2ed28022 (diff) | |
download | haskell-6740d70d95cb81cea3859ff847afc61ec439db4f.tar.gz |
Use IP based CallStack in error and undefined
This patch modifies `error`, `undefined`, and `assertError` to use
implicit call-stacks to provide better error messages to users.
There are a few knock-on effects:
- `GHC.Classes.IP` is now wired-in so it can be used in the wired-in
types for `error` and `undefined`.
- `TysPrim.tyVarList` has been replaced with a new function
`TysPrim.mkTemplateTyVars`. `tyVarList` made it easy to introduce
subtle bugs when you need tyvars of different kinds. The naive
```
tv1 = head $ tyVarList kind1
tv2 = head $ tyVarList kind2
```
would result in `tv1` and `tv2` sharing a `Unique`, thus substitutions
would be applied incorrectly, treating `tv1` and `tv2` as the same
tyvar. `mkTemplateTyVars` avoids this pitfall by taking a list of kinds
and producing a single tyvar of each kind.
- The types `GHC.SrcLoc.SrcLoc` and `GHC.Stack.CallStack` now live in
ghc-prim.
- The type `GHC.Exception.ErrorCall` has a new constructor
`ErrorCallWithLocation` that takes two `String`s instead of one, the
2nd one being arbitrary metadata about the error (but usually the
call-stack). A bi-directional pattern synonym `ErrorCall` continues to
provide the old API.
Updates Cabal, array, and haddock submodules.
Reviewers: nh2, goldfire, simonpj, hvr, rwbarton, austin, bgamari
Reviewed By: simonpj
Subscribers: rwbarton, rodlogic, goldfire, maoe, simonmar, carter,
liyang, bgamari, thomie
Differential Revision: https://phabricator.haskell.org/D861
GHC Trac Issues: #5273
Diffstat (limited to 'compiler/typecheck/TcBinds.hs')
-rw-r--r-- | compiler/typecheck/TcBinds.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/typecheck/TcBinds.hs b/compiler/typecheck/TcBinds.hs index 8a7ca4d5c1..897828d5ec 100644 --- a/compiler/typecheck/TcBinds.hs +++ b/compiler/typecheck/TcBinds.hs @@ -37,6 +37,7 @@ import FamInst( tcGetFamInstEnvs ) import TyCon import TcType import TysPrim +import TysWiredIn import Id import Var import VarSet @@ -56,7 +57,7 @@ import BasicTypes import Outputable import FastString import Type(mkStrLitTy) -import PrelNames( ipClassName, gHC_PRIM ) +import PrelNames( gHC_PRIM ) import TcValidity (checkValidType) import Control.Monad @@ -225,8 +226,7 @@ tcLocalBinds (HsValBinds (ValBindsOut binds sigs)) thing_inside tcLocalBinds (HsValBinds (ValBindsIn {})) _ = panic "tcLocalBinds" tcLocalBinds (HsIPBinds (IPBinds ip_binds _)) thing_inside - = do { ipClass <- tcLookupClass ipClassName - ; (given_ips, ip_binds') <- + = do { (given_ips, ip_binds') <- mapAndUnzipM (wrapLocSndM (tc_ip_bind ipClass)) ip_binds -- If the binding binds ?x = E, we must now |