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

unexpected "impossible" exception in lexer #5179

Open
ceedubs opened this issue Jul 4, 2024 · 1 comment
Open

unexpected "impossible" exception in lexer #5179

ceedubs opened this issue Jul 4, 2024 · 1 comment
Labels

Comments

@ceedubs
Copy link
Contributor

ceedubs commented Jul 4, 2024

Describe and demonstrate the bug

I see this error in my terminal, though seems seem to continue to run fine. I think that it may be coming from an LSP thread similar to #4737.

 Uh oh, an unexpected exception brought the process down! That should never happen. Please file a bug report.

Here's a stringy rendering of the exception:

  impossible
  CallStack (from HasCallStack):
    error, called at src/Unison/Syntax/Lexer.hs:241:22 in unison-syntax-0.0.0-3wBkjZ3Vjv91L4a1yNKHwZ:Unison.Syntax.Lexer

I'm not exactly sure what caused this. But I think that it was something like this:

  • add a type to the project and a function that matches on one of its constructors
  • Bring the type and the function into your scratch file
  • Add an argument to the constructor, and modify the function to use it. Save the file but don't update.
  • Delete or comment out the updated type, but leave the function depending on the modified constructor in the scratch file.

I'm using LSP; not sure how relevant that is

Environment (please complete the following information):

  • ucm --version a74d4e8
  • OS/Architecture: x86 NixOS
  • Editor: Neovim with lspconfig
@ceedubs ceedubs added the bug label Jul 4, 2024
@sellout
Copy link
Contributor

sellout commented Jul 9, 2024

Here’s the code at that commit:

pops :: Pos -> P [Token Lexeme]
pops p = do
env <- S.get
let l = layout env
if top l == column p && topContainsVirtualSemis l
then pure [Token (Semi True) p p]
else
if column p > top l || topHasClosePair l
then pure []
else
if column p < top l
then S.put (env {layout = pop l}) >> ((Token Close p p :) <$> pops p)
else error "impossible"

A first step might just be returning a parser failure rather than error (and maybe changing the description).

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

No branches or pull requests

2 participants