unison
unison copied to clipboard
Parse failure if the last line in a scratch file is `use`
To reproduce, save this file:
a = ()
use .base
Error:
/home/mitchell/unison/junk/scratch.u:1:3:
unexpected =
1 | a = ()
Ah, this is because when we reorder stanzas to bring use and types to the top, we don’t introduce any virtual semis. So, if they were the last item the following stanza becomes part of it.
I.e., the parser effectively sees
use .base a = ()
This also occurs in any block, not just EOF. E.g., with
a = let
x = 3
x
use .base
b = 3
the parser sees
a = let
use .base x = 3
x
I noticed this when updating the parser, but avoided changing it at the time, because I figured I was overlooking some aspect of the reordering, so I carefully preserved the bug 😅