From 5631af136c5cb9f0e43ed2c288beb23a50c86552 Mon Sep 17 00:00:00 2001 From: Adam Boniecki Date: Wed, 16 Nov 2022 16:22:14 +0100 Subject: [PATCH] Fix the issue The problem was that we had some cached lexer state when reading new input during FSI session. If lexer threw an error on a very first token of new input, the cached lexer state would not get updated, so we would assosciate old lexer state with this new token that caused an error. Now we will invalidate that cached state at the begining of reading new input. --- src/Compiler/SyntaxTree/LexFilter.fs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Compiler/SyntaxTree/LexFilter.fs b/src/Compiler/SyntaxTree/LexFilter.fs index 88a743a6bf2..14a43332424 100644 --- a/src/Compiler/SyntaxTree/LexFilter.fs +++ b/src/Compiler/SyntaxTree/LexFilter.fs @@ -699,6 +699,8 @@ type LexFilterImpl ( let mutable prevWasAtomicEnd = false let peekInitial() = + // Forget the lexbuf state we might have saved from previous input + haveLexbufState <- false let initialLookaheadTokenTup = popNextTokenTup() if debug then dprintf "first token: initialLookaheadTokenLexbufState = %a\n" outputPos (startPosOfTokenTup initialLookaheadTokenTup)