Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite incomplete pattern matches with stub #15

Open
yaitskov opened this issue Dec 13, 2021 · 1 comment
Open

Rewrite incomplete pattern matches with stub #15

yaitskov opened this issue Dec 13, 2021 · 1 comment

Comments

@yaitskov
Copy link

yaitskov commented Dec 13, 2021

GHC doesn't generate stack trace in case of incomplete pattern match.

Up to date
App/DepB.hs:7:1-14: Non-exhaustive patterns in function fB
fB :: HasCallStack => Int -> Int
fB 1 = 1 

Would be cool to append default case to fB

fB :: HasCallStack => Int -> Int
fB 1 = 1 
fB o = error $ "DepB.fB is not implemented for " ++ show o

Then output is much more informative:

CallStack (from HasCallStack):
  error, called at ../App/DepB.hs:8:8 in main:DepB
  fB, called at ../App/DepA.hs:7:8 in main:.DepA
  fA, called at ../App/Main.hs:108:23 in main:Spec

@bitc
Copy link

bitc commented Jan 11, 2022

I think it would be better to add this feature directly to GHC, so that everyone gets a stack trace, and not just those of us who use this plugin.

And while we are at it, in addition to incomplete pattern match, we should also give stack trace to the error Missing field in record construction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants