unison icon indicating copy to clipboard operation
unison copied to clipboard

unexpected "impossible" exception in lexer

Open ceedubs opened this issue 1 year ago • 3 comments

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 a74d4e8cb
  • OS/Architecture: x86 NixOS
  • Editor: Neovim with lspconfig

ceedubs avatar Jul 04 '24 01:07 ceedubs

Here’s the code at that commit: https://github.com/unisonweb/unison/blob/a74d4e8cb9cd860ebd79e348f8012f57625e2239/unison-syntax/src/Unison/Syntax/Lexer.hs#L229-L241

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

sellout avatar Jul 09 '24 05:07 sellout

Is this closed as of #5297?

aryairani avatar Sep 24 '24 03:09 aryairani

I don’t think so – this has just hopefully made the failure more informative when it occurs again (since it‘s clearly not impossible).

Since this is an failure in the lexer, I don’t think Cody’s sequence of steps is helpful to replicate it, especially since it seems to be a result of the background LSP thread.

sellout avatar Sep 24 '24 06:09 sellout