Skip to content

Conversation

@abonie
Copy link
Member

@abonie abonie commented Nov 16, 2022

Fixes #13139, #9631

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.

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.
@abonie abonie requested a review from a team as a code owner November 16, 2022 15:29
@abonie
Copy link
Member Author

abonie commented Nov 16, 2022

Testing manually is easy, but I don't know how to write a test for this, as this issue only appears in FSI session after a sequence of inputs:

> 0;;
val it: int = 0

> 1.Asdf;;

  1.Asdf;;
  ^^^^^^

stdin(2,1): error FS1156: This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint).

> x;;

  1.Asdf;;
  ^

stdin(2,1): error FS0039: The value or constructor 'x' is not defined.

>

@abonie abonie changed the title Fix the issue Fix error reporting in fsi after a lexer error Nov 16, 2022
@vzarytovskii
Copy link
Member

Testing manually is easy, but I don't know how to write a test for this, as this issue only appears in FSI session after a sequence of inputs:

> 0;;
val it: int = 0

> 1.Asdf;;

  1.Asdf;;
  ^^^^^^

stdin(2,1): error FS1156: This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint).

> x;;

  1.Asdf;;
  ^

stdin(2,1): error FS0039: The value or constructor 'x' is not defined.

>

Maybe worth extending our testing framework, having eval or runFsi -like function which accepts a sequence of submissions and simulates multi submission to FSI?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Calling a method on an invalid numeric literal completely breaks error reporting in fsi

4 participants