Use IP based CallStack in error and undefined
authorEric Seidel <gridaphobe@gmail.com>
Wed, 2 Sep 2015 08:22:01 +0000 (10:22 +0200)
committerBen Gamari <ben@smart-cactus.org>
Wed, 2 Sep 2015 11:21:43 +0000 (13:21 +0200)
commit6740d70d95cb81cea3859ff847afc61ec439db4f
tree08199080ae5e55aafa1ff05cffd929039d3345bf
parentad26c54b86a868567d324d5de6fd0b4c2ed28022
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
48 files changed:
compiler/basicTypes/MkId.hs
compiler/coreSyn/MkCore.hs
compiler/iface/IfaceType.hs
compiler/prelude/PrelNames.hs
compiler/prelude/TysPrim.hs
compiler/prelude/TysWiredIn.hs
compiler/typecheck/TcBinds.hs
compiler/typecheck/TcExpr.hs
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcInteract.hs
compiler/typecheck/TcTypeNats.hs
compiler/types/Type.hs
compiler/types/TypeRep.hs
docs/users_guide/7.12.1-notes.xml
docs/users_guide/glasgow_exts.xml
libraries/Cabal
libraries/array
libraries/base/Control/Exception.hs
libraries/base/Control/Exception/Base.hs
libraries/base/GHC/Err.hs
libraries/base/GHC/Exception.hs
libraries/base/GHC/Exception.hs-boot
libraries/base/GHC/IO/Exception.hs
libraries/base/GHC/SrcLoc.hs [deleted file]
libraries/base/GHC/Stack.hsc
libraries/base/base.cabal
libraries/base/tests/assert.stderr
libraries/ghc-prim/GHC/Types.hs
testsuite/tests/annotations/should_fail/annfail12.stderr
testsuite/tests/cabal/cabal07/cabal07.stderr
testsuite/tests/deriving/should_run/T9576.stderr
testsuite/tests/driver/T1372/T1372.stderr
testsuite/tests/ghci.debugger/scripts/break009.stdout
testsuite/tests/ghci.debugger/scripts/break011.stdout
testsuite/tests/ghci.debugger/scripts/break017.stdout
testsuite/tests/ghci/scripts/T10501.stderr
testsuite/tests/ghci/scripts/T5557.stdout
testsuite/tests/ghci/scripts/ghci055.stdout
testsuite/tests/perf/compiler/all.T
testsuite/tests/simplCore/should_compile/EvalTest.stdout
testsuite/tests/simplCore/should_compile/T4930.hs
testsuite/tests/simplCore/should_compile/T4930.stderr
testsuite/tests/th/T5358.stderr
testsuite/tests/th/T5976.stderr
testsuite/tests/th/T7276a.stdout
testsuite/tests/th/T8987.stderr
testsuite/tests/th/TH_exn2.stderr
utils/haddock