Hide the `error` call from `undefined`s call stack
When using undefined
, users might see a call stack like
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
The first line of this call stack provides no new information. undefined
will always call error, and it's not exactly surprising. It is detrimental for readability, though: Multiple times, I went to line 79 in my source file instead of to the line the undefined
call was in.
Therefore, it would be better if this line did not appear in the call stack, which can be achieved by using errorWithoutCallStack
instead
Edit: This is wrong, see #19886 (comment 354430)