summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Breitner <mail@joachim-breitner.de>2021-10-14 18:57:54 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-24 01:27:57 -0400
commit3417a81a34fdf74857138a105b2ab4ee32e658c4 (patch)
tree22e4f7228512698fa93bc093d463be96f7ad6939
parent691c450f1e9cc3fd83b662be3c0134fde03e97db (diff)
downloadhaskell-3417a81a34fdf74857138a105b2ab4ee32e658c4.tar.gz
undefined: Neater CallStack in error message
Users of `undefined` don’t want to see ``` files.hs: Prelude.undefined: CallStack (from HasCallStack): error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err undefined, called at file.hs:151:19 in main:Main ``` but want to see ``` files.hs: Prelude.undefined: CallStack (from HasCallStack): undefined, called at file.hs:151:19 in main:Main ``` so let’s make that so. The function for that is `withFrozenCallStack`, but that is not usable here (module dependencies, and also not representation-polymorphic). And even if it were, it could confuse GHC’s strictness analyzer, leading to big regressions in some perf tests (T10421 in particular). So after shuffling modules and definitions around, I eventually noticed that the easiest way is to just not call `error` here. Fixes #19886
-rw-r--r--libraries/base/GHC/Err.hs8
-rw-r--r--testsuite/tests/codeGen/should_run/T16846.stderr1
-rw-r--r--testsuite/tests/codeGen/should_run/T5626.stderr3
-rw-r--r--testsuite/tests/deSugar/should_run/T11572.stderr1
-rw-r--r--testsuite/tests/deSugar/should_run/T11601.stderr1
-rw-r--r--testsuite/tests/ghci.debugger/scripts/break017.stdout1
-rw-r--r--testsuite/tests/ghci/scripts/T10501.stderr3
-rw-r--r--testsuite/tests/ghci/scripts/T5557.stdout2
-rw-r--r--testsuite/tests/ghci/scripts/ghci055.stdout3
-rw-r--r--testsuite/tests/simplCore/should_fail/T7411.stderr3
-rw-r--r--testsuite/tests/simplCore/should_run/T16893/T16893.stderr1
-rw-r--r--testsuite/tests/simplCore/should_run/T5625.stderr3
-rw-r--r--testsuite/tests/th/T19470.stderr1
-rw-r--r--testsuite/tests/th/T8987.stderr1
-rw-r--r--testsuite/tests/typecheck/should_compile/T17343.stderr3
15 files changed, 13 insertions, 22 deletions
diff --git a/libraries/base/GHC/Err.hs b/libraries/base/GHC/Err.hs
index 87f3e46bd7..07d263bf7d 100644
--- a/libraries/base/GHC/Err.hs
+++ b/libraries/base/GHC/Err.hs
@@ -71,7 +71,13 @@ errorWithoutStackTrace s = raise# (errorCallException s)
-- appears.
undefined :: forall (r :: RuntimeRep). forall (a :: TYPE r).
HasCallStack => a
-undefined = error "Prelude.undefined"
+-- This used to be
+-- undefined = error "Prelude.undefined"
+-- but that would add an extra call stack entry that is not actually helpful
+-- nor wanted (see #19886). We’d like to use withFrozenCallStack, but that
+-- is not available in this module yet, and making it so is hard. So let’s just
+-- use raise# directly.
+undefined = raise# (errorCallWithCallStackException "Prelude.undefined" ?callStack)
-- | Used for compiler-generated error message;
-- encoding saves bytes of string junk.
diff --git a/testsuite/tests/codeGen/should_run/T16846.stderr b/testsuite/tests/codeGen/should_run/T16846.stderr
index f737c83af0..3d1cbeef10 100644
--- a/testsuite/tests/codeGen/should_run/T16846.stderr
+++ b/testsuite/tests/codeGen/should_run/T16846.stderr
@@ -1,4 +1,3 @@
T16846: Prelude.undefined
CallStack (from HasCallStack):
- error, called at libraries/base/GHC/Err.hs:80:14 in base:GHC.Err
undefined, called at T16846.hs:22:3 in main:Main
diff --git a/testsuite/tests/codeGen/should_run/T5626.stderr b/testsuite/tests/codeGen/should_run/T5626.stderr
index 2c02bb0a5c..921c69a8cd 100644
--- a/testsuite/tests/codeGen/should_run/T5626.stderr
+++ b/testsuite/tests/codeGen/should_run/T5626.stderr
@@ -1,4 +1,3 @@
T5626: Prelude.undefined
-CallStack (from ImplicitParams):
- error, called at libraries/base/GHC/Err.hs:43:14 in base:GHC.Err
+CallStack (from HasCallStack):
undefined, called at T5626.hs:6:30 in main:Main
diff --git a/testsuite/tests/deSugar/should_run/T11572.stderr b/testsuite/tests/deSugar/should_run/T11572.stderr
index b1136024db..c4a5ee0044 100644
--- a/testsuite/tests/deSugar/should_run/T11572.stderr
+++ b/testsuite/tests/deSugar/should_run/T11572.stderr
@@ -1,4 +1,3 @@
T11572: Prelude.undefined
CallStack (from HasCallStack):
- error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
undefined, called at T11572.hs:6:18 in main:Main
diff --git a/testsuite/tests/deSugar/should_run/T11601.stderr b/testsuite/tests/deSugar/should_run/T11601.stderr
index de0d9deb91..29f6bef297 100644
--- a/testsuite/tests/deSugar/should_run/T11601.stderr
+++ b/testsuite/tests/deSugar/should_run/T11601.stderr
@@ -1,4 +1,3 @@
T11601: Prelude.undefined
CallStack (from HasCallStack):
- error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
undefined, called at T11601.hs:6:35 in main:Main
diff --git a/testsuite/tests/ghci.debugger/scripts/break017.stdout b/testsuite/tests/ghci.debugger/scripts/break017.stdout
index af22c066e6..28a1d23dff 100644
--- a/testsuite/tests/ghci.debugger/scripts/break017.stdout
+++ b/testsuite/tests/ghci.debugger/scripts/break017.stdout
@@ -12,7 +12,6 @@ as = 'b' : 'c' : (_t1::[Char])
Forcing
*** Exception: Prelude.undefined
CallStack (from HasCallStack):
- error, called at libraries/base/GHC/Err.hs:75:14 in base:GHC.Err
undefined, called at <interactive>:3:17 in interactive:Ghci1
Printing 2
as = 'b' : 'c' : (_t2::[Char])
diff --git a/testsuite/tests/ghci/scripts/T10501.stderr b/testsuite/tests/ghci/scripts/T10501.stderr
index 65d24a08ca..669b72bf45 100644
--- a/testsuite/tests/ghci/scripts/T10501.stderr
+++ b/testsuite/tests/ghci/scripts/T10501.stderr
@@ -1,5 +1,4 @@
*** Exception: Prelude.head: empty list
*** Exception: Prelude.undefined
-CallStack (from ImplicitParams):
- error, called at libraries/base/GHC/Err.hs:50:14 in base:GHC.Err
+CallStack (from HasCallStack):
undefined, called at <interactive>:1:17 in interactive:Ghci1
diff --git a/testsuite/tests/ghci/scripts/T5557.stdout b/testsuite/tests/ghci/scripts/T5557.stdout
index 4b864f9063..836595f60a 100644
--- a/testsuite/tests/ghci/scripts/T5557.stdout
+++ b/testsuite/tests/ghci/scripts/T5557.stdout
@@ -1,8 +1,6 @@
*** Exception: Prelude.undefined
CallStack (from HasCallStack):
- error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
undefined, called at <interactive>:2:12 in interactive:Ghci1
*** Exception: Prelude.undefined
CallStack (from HasCallStack):
- error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
undefined, called at <interactive>:3:12 in interactive:Ghci1
diff --git a/testsuite/tests/ghci/scripts/ghci055.stdout b/testsuite/tests/ghci/scripts/ghci055.stdout
index c40e0d073e..5cf7bc6bc5 100644
--- a/testsuite/tests/ghci/scripts/ghci055.stdout
+++ b/testsuite/tests/ghci/scripts/ghci055.stdout
@@ -1,6 +1,5 @@
*** Exception: Prelude.undefined
CallStack (from HasCallStack):
- error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
- undefined, called at <interactive>:1:5 in interactive:Ghci1
+ undefined, called at <interactive>:1:7 in interactive:Ghci1
x :: a = _
y :: Int = 3
diff --git a/testsuite/tests/simplCore/should_fail/T7411.stderr b/testsuite/tests/simplCore/should_fail/T7411.stderr
index 6fc6a22560..9a72acaf2c 100644
--- a/testsuite/tests/simplCore/should_fail/T7411.stderr
+++ b/testsuite/tests/simplCore/should_fail/T7411.stderr
@@ -1,4 +1,3 @@
T7411: Prelude.undefined
-CallStack (from ImplicitParams):
- error, called at libraries/base/GHC/Err.hs:43:14 in base:GHC.Err
+CallStack (from HasCallStack):
undefined, called at T7411.hs:3:25 in main:Main
diff --git a/testsuite/tests/simplCore/should_run/T16893/T16893.stderr b/testsuite/tests/simplCore/should_run/T16893/T16893.stderr
index 5dfa1d642f..c077f4bed1 100644
--- a/testsuite/tests/simplCore/should_run/T16893/T16893.stderr
+++ b/testsuite/tests/simplCore/should_run/T16893/T16893.stderr
@@ -1,4 +1,3 @@
T16893: Prelude.undefined
CallStack (from HasCallStack):
- error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
undefined, called at ./Complex.hs:47:28 in main:Complex
diff --git a/testsuite/tests/simplCore/should_run/T5625.stderr b/testsuite/tests/simplCore/should_run/T5625.stderr
index fe02e7e6a8..a935ab7af8 100644
--- a/testsuite/tests/simplCore/should_run/T5625.stderr
+++ b/testsuite/tests/simplCore/should_run/T5625.stderr
@@ -1,4 +1,3 @@
T5625: Prelude.undefined
-CallStack (from ImplicitParams):
- error, called at libraries/base/GHC/Err.hs:43:14 in base:GHC.Err
+CallStack (from HasCallStack):
undefined, called at T5625.hs:3:31 in main:Main
diff --git a/testsuite/tests/th/T19470.stderr b/testsuite/tests/th/T19470.stderr
index aaf251d086..86788d1b73 100644
--- a/testsuite/tests/th/T19470.stderr
+++ b/testsuite/tests/th/T19470.stderr
@@ -3,7 +3,6 @@
• Exception when trying to run compile-time code:
Prelude.undefined
CallStack (from HasCallStack):
- error, called at libraries/base/GHC/Err.hs:74:14 in base:GHC.Err
undefined, called at <interactive>:2:10 in interactive:Ghci1
Code: undefined
• In the Template Haskell splice $$undefined
diff --git a/testsuite/tests/th/T8987.stderr b/testsuite/tests/th/T8987.stderr
index 00181fa2db..9933ef3465 100644
--- a/testsuite/tests/th/T8987.stderr
+++ b/testsuite/tests/th/T8987.stderr
@@ -3,6 +3,5 @@ T8987.hs:1:1: error:
Exception when trying to run compile-time code:
Prelude.undefined
CallStack (from HasCallStack):
- error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
undefined, called at T8987.hs:6:23 in main:T8987
Code: (reportWarning ['1', undefined] >> return [])
diff --git a/testsuite/tests/typecheck/should_compile/T17343.stderr b/testsuite/tests/typecheck/should_compile/T17343.stderr
index 044fa41d77..db8aa1c74a 100644
--- a/testsuite/tests/typecheck/should_compile/T17343.stderr
+++ b/testsuite/tests/typecheck/should_compile/T17343.stderr
@@ -1,4 +1,3 @@
T17343: Prelude.undefined
CallStack (from HasCallStack):
- error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
- undefined, called at T17343.hs:4:5 in main:Main
+ undefined, called at T17343.hs:4:11 in main:Main