You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Send-to-interactive of incomplete string leaves FSI waiting for more input #830
Area-VS-FSIVS window and commands for F# InteractiveFeature ImprovementTheme-Simple-F#A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.
changed the title [-]Parser confused by the presence of string literals in multi-line comments[/-][+]Parser confused by the presence of unterminated string literals in multi-line comments[/+]on Dec 23, 2015
Please check the F# language spec - string literals in comments are parsed as string literals. This allows for commenting-out of code involving "...*)..." strings and is the same as OCaml
But the true weirdness you're seeing is that sending incomplete strings to F# Interactive causes F# interactive to wait for the completion of the string. I've changed the title to reflect that
changed the title [-]Parser confused by the presence of unterminated string literals in multi-line comments[/-][+]Send-to-interactive of incomplete string leaves FSI waiting for more input[/+]on Jan 8, 2016
I had noticed that the same behaviour occurs in OCaml but I thought this was more of an inherited bug rather than something added by design. It seems very odd! For the record, multi-line comments in the C family of languages don't demonstrate this behaviour (they also don't permit nested comments).
@dsyme@eiriktsarpalis I'm not following the ask here. FSI waits on incomplete strings until the user ends them (multi-line strings). This is demonstrated by typing:
fsi.exe
"start
end"
Isn't this the expected behavior? shouldn't FSI wait for strings to be terminated?
I think the ask is that Visual Studio should not send incomplete fragments to the fsi.exe process - it should check the fragments are complete (i.e. expressions or FSI-acceptable declarations) before sending them, and give a meaningful UI error if they are not complete.
Side note: with the merge of #1582, this should open the door to implementing an interactive window based on Roslyn, which means that we would get colorization, intellisense, and other features in the interactive window for free.
Let me copy my message from the dupe thread, in case it's sensible:
Perhaps an improvement is to show a message hint on enter, since that usually executes what's already there: "Quoted string detected that wasn't properly closed, expected a quote character."
Or recognize ';;' even when it's inside a non-closed string, as the end of the statement, perhaps provided that it's the last two characters. It's unlikely the programmer meant anything else.
The real problem is we send-to-interactive via standard input. It's really hard to send a delimter that says "end of input fragment" for that,
For fsi.exe on Windows we could in theory use send-to-interactive via the backdoor .NET remoting connection we open for sending interrupt signals. However that backdoor won't be available for .NET Core and we will have to send interruprt signals another way. I suppose we are goign to have to solve both problems by sending some awful magic string to the standard input.
I'm not particularly happy with this approach but I'm not sure what else to do
@dsyme, I understand from this that fsi uses line input, as in Console.ReadLine? But somehow the current implementation knows the difference on hitting Enter with two semicolons before it, or with an unfinished statement or string. Surely that logic is coded somewhere and we could improve that?
@dsyme, I understand from this that fsi uses line input, as in Console.ReadLine? But somehow the current implementation knows the difference on hitting Enter with two semicolons before it, or with an unfinished statement or string. Surely that logic is coded somewhere and we could improve that?
The current implementation knows about ";;" as a token causing the production of an interactive fragment. It knows nothing if the ";;" occurs in an unterminated string (it assumes it is part of the string and waits for more input), and indeed knows nothing about unterminated strings in general. There is logic for unterminated strings when EOF is reached but there is no EOF in this case.
I've tried if string interpolation (#8907) works in latest fsi.
dotnet fsi --langversion:preview
Microsoft (R) F# Interactive version 10.10.0.0for F# 4.7
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;>lets="world";;vals:string = "world"
> $"Hello {s}";;
$"Hello {s}";;^^/home/peterk/tmp/stdin(2,1): error FS1160: This token is reserved for future use-;;---Interrupt- #help;- #help;;--
Area-VS-FSIVS window and commands for F# InteractiveFeature ImprovementTheme-Simple-F#A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.
Activity
[-]Parser confused by the presence of string literals in multi-line comments[/-][+]Parser confused by the presence of unterminated string literals in multi-line comments[/+]dsyme commentedon Jan 8, 2016
Please check the F# language spec - string literals in comments are parsed as string literals. This allows for commenting-out of code involving
"...*)..."strings and is the same as OCamlBut the true weirdness you're seeing is that sending incomplete strings to F# Interactive causes F# interactive to wait for the completion of the string. I've changed the title to reflect that
[-]Parser confused by the presence of unterminated string literals in multi-line comments[/-][+]Send-to-interactive of incomplete string leaves FSI waiting for more input[/+]eiriktsarpalis commentedon Jan 12, 2016
I had noticed that the same behaviour occurs in OCaml but I thought this was more of an inherited bug rather than something added by design. It seems very odd! For the record, multi-line comments in the C family of languages don't demonstrate this behaviour (they also don't permit nested comments).
OmarTawfik commentedon Mar 2, 2016
@dsyme @eiriktsarpalis I'm not following the ask here. FSI waits on incomplete strings until the user ends them (multi-line strings). This is demonstrated by typing:
Isn't this the expected behavior? shouldn't FSI wait for strings to be terminated?
dsyme commentedon Mar 4, 2016
I think the ask is that Visual Studio should not send incomplete fragments to the fsi.exe process - it should check the fragments are complete (i.e. expressions or FSI-acceptable declarations) before sending them, and give a meaningful UI error if they are not complete.
OmarTawfik commentedon Oct 6, 2016
Side note: with the merge of #1582, this should open the door to implementing an interactive window based on Roslyn, which means that we would get colorization, intellisense, and other features in the interactive window for free.
4 remaining items
abelbraaksma commentedon Oct 11, 2018
Let me copy my message from the dupe thread, in case it's sensible:
Perhaps an improvement is to show a message hint on enter, since that usually executes what's already there: "Quoted string detected that wasn't properly closed, expected a quote character."
Or recognize ';;' even when it's inside a non-closed string, as the end of the statement, perhaps provided that it's the last two characters. It's unlikely the programmer meant anything else.
abelbraaksma commentedon Oct 11, 2018
Please note that this applies both to the 'send to' and direct typing into fsi functionalities.
dsyme commentedon Oct 12, 2018
The real problem is we send-to-interactive via standard input. It's really hard to send a delimter that says "end of input fragment" for that,
For fsi.exe on Windows we could in theory use send-to-interactive via the backdoor .NET remoting connection we open for sending interrupt signals. However that backdoor won't be available for .NET Core and we will have to send interruprt signals another way. I suppose we are goign to have to solve both problems by sending some awful magic string to the standard input.
I'm not particularly happy with this approach but I'm not sure what else to do
abelbraaksma commentedon Oct 12, 2018
@dsyme, I understand from this that fsi uses line input, as in Console.ReadLine? But somehow the current implementation knows the difference on hitting Enter with two semicolons before it, or with an unfinished statement or string. Surely that logic is coded somewhere and we could improve that?
dsyme commentedon Oct 15, 2018
The current implementation knows about ";;" as a token causing the production of an interactive fragment. It knows nothing if the ";;" occurs in an unterminated string (it assumes it is part of the string and waits for more input), and indeed knows nothing about unterminated strings in general. There is logic for unterminated strings when EOF is reached but there is no EOF in this case.
pkese commentedon Aug 12, 2020
Similar problem...
I've tried if string interpolation (#8907) works in latest fsi.
dotnet fsi --langversion:preview...can't find a way to terminate input.