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

In FSI, an invalid string literal can break further parsing of string in that interactive session #14160

Open
abonie opened this issue Oct 21, 2022 · 8 comments · Fixed by #14182
Labels
Area-FSI Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone

Comments

@abonie
Copy link
Member

abonie commented Oct 21, 2022

In FSI, inputting an interpolated string literal that opens interpolation expression with { but does not close it, e.g. $"{" breaks the session in a way that further valid string literals can no longer be parsed

Repro steps

In dotnet fsi try:

> $"{";;

followed by any(?) string literal, e.g. empty string:

> "";;

Full session example:

# dotnet fsi

Microsoft (R) F# Interactive version 12.0.5.0 for F# 7.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> $"{";;

  $"{";;
  ---^

stdin(1,4): error FS3373: Invalid interpolated string. Single quote or verbatim string literals may not be used in interpolated expressions in single quote or verbatim strings. Consider using an explicit 'let' binding for the interpolation expression or use a triple quote string as the outer string literal.

> "";;

  "";;
  ^

stdin(2,1): error FS3373: Invalid interpolated string. Single quote or verbatim string literals may not be used in interpolated expressions in single quote or verbatim strings. Consider using an explicit 'let' binding for the interpolation expression or use a triple quote string as the outer string literal.


  $"{";;
  -----^

stdin(1,6): error FS3373: Invalid interpolated string. Single quote or verbatim string literals may not be used in interpolated expressions in single quote or verbatim strings. Consider using an explicit 'let' binding for the interpolation expression or use a triple quote string as the outer string literal.

> > ;;
> "";;

  ;;
  ^

stdin(3,1): error FS3373: Invalid interpolated string. Single quote or verbatim string literals may not be used in interpolated expressions in single quote or verbatim strings. Consider using an explicit 'let' binding for the interpolation expression or use a triple quote string as the outer string literal.


  "";;
  --^

stdin(2,3): error FS3373: Invalid interpolated string. Single quote or verbatim string literals may not be used in interpolated expressions in single quote or verbatim strings. Consider using an explicit 'let' binding for the interpolation expression or use a triple quote string as the outer string literal.

> >

Note: the invalid input results in "error FS3373: Invalid interpolated string", however not all inputs that result in this particular error are followed by this buggy behavior, e.g. $"{""}" or $"{"}" result in error FS3373, but don't break the session.

Expected behavior

Valid string literals are parsed correctly, regardless of erroneous input that happened earlier in that same interactive session.

Actual behavior

Certain inputs make FSI unable to parse valid strings afterwards.

Known workarounds

Close FSI session and open a new one

Related information

Provide any related information (optional):

  • Operating system: Windows 11
  • .NET Runtime kind: dotnet core 7.0.100-rc.2.22477.23
@github-actions github-actions bot added this to the Backlog milestone Oct 21, 2022
@vzarytovskii vzarytovskii moved this to Not Planned in F# Compiler and Tooling Oct 21, 2022
@abonie abonie added Area-FSI Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. labels Oct 21, 2022
@abonie abonie self-assigned this Oct 26, 2022
@abonie
Copy link
Member Author

abonie commented Oct 26, 2022

I think I incidentally stumbled upon a solution as I've been working on lexing recently, so I am looking into this issue.

No clue how to unit test this yet though.

@abonie abonie modified the milestones: Backlog, November-2022 Oct 31, 2022
@abonie abonie removed the Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. label Nov 4, 2022
Repository owner moved this from Not Planned to Done in F# Compiler and Tooling Nov 7, 2022
@abonie
Copy link
Member Author

abonie commented Feb 16, 2023

Reopening as #14182 had to be reverted due to #14757

@abonie abonie reopened this Feb 16, 2023
@github-project-automation github-project-automation bot moved this from Done to In Progress in F# Compiler and Tooling Feb 16, 2023
@abonie abonie removed their assignment Mar 16, 2023
@MrLuje
Copy link

MrLuje commented Apr 28, 2023

I have a similiar behavior (broker parsing) that doesn't involve "{", should I open a different issue ?

let cst = "Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@37d688b1-org.sonar.scanner.bootstrap.ScannerPluginRepository': Initialization of bean failed"

Send it 4 times to FSI

  • works fine
  • works fine
  • shows the command but doesn't print the variable
  • breaks

FSI

Microsoft (R) F# Interactive version 12.5.0.0 for F# 7.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> # silentCd @"/home/vince/src/github/mrluje/fs-gitlab-stats";;
- # 1 @"/home/vince/src/github/mrluje/fs-gitlab-stats/test.fsx"
- ;;
> let cst = "Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@37d688b1-org.sonar.scanner.bootstrap.ScannerPluginRepository': Initialization of bean failed";;
val cst: string =  "Error creating bean with name 'org.sonarsource.scanner.api.in"+[119 chars]

> let cst = "Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@37d688b1-org.sonar.scanner.bootstrap.ScannerPluginRepository': Initialization of bean failed";;
val cst: string =  "Error creating bean with name 'org.sonarsource.scanner.api.in"+[119 chars]

> ";; cst = "Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@37d688b1-org.sonar.scanner.bootstrap.ScannerPluginRepository': Initialization of bean faile
- let cst = "Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@37d688b1-org.sonar.scanner.bootstrap.ScannerPluginRepository': Initialization of bean faile

error FS0193: Operation is not supported on this platform.

> ";;
- 

@abonie
Copy link
Member Author

abonie commented Jun 19, 2023

@MrLuje how are you sending the input to FSI in your example? Because it looks like the input got mangled the third time it was sent. Does not seem to be the same issue.

@MrLuje
Copy link

MrLuje commented Jun 19, 2023

@abonie with ionide extension (v7.7.0) on vscode with either "FSI: send selection" or "FSI: send line"

@abonie
Copy link
Member Author

abonie commented Jun 22, 2023

Hmm... It does not repro for me at least on the same version of ionide

@MrLuje
Copy link

MrLuje commented Jun 22, 2023

I didn't check before but it looks like it is only failing from WSL

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"

$ uname -a
Linux HVS-PF346A2W 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

I can't reproduce it either from windows

@T-Gro
Copy link
Member

T-Gro commented Jul 31, 2024

@abonie : Is this still relevant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-FSI Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

3 participants