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

Send-to-interactive of incomplete string leaves FSI waiting for more input #830

Open
eiriktsarpalis opened this issue Dec 23, 2015 · 12 comments
Labels
Area-VS-FSI VS window and commands for F# Interactive Feature Improvement Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.
Milestone

Comments

@eiriktsarpalis
Copy link
Member

See https://twitter.com/eiriktsarpalis/status/679692748182663168 for a reproduction.

@eiriktsarpalis eiriktsarpalis 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 Dec 23, 2015
@dsyme
Copy link
Contributor

dsyme commented 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 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

@dsyme dsyme 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 Jan 8, 2016
@dsyme dsyme added the Area-VS-FSI VS window and commands for F# Interactive label Jan 8, 2016
@eiriktsarpalis
Copy link
Member Author

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 dsyme added Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. labels Jan 12, 2016
@OmarTawfik
Copy link
Contributor

@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?

@dsyme
Copy link
Contributor

dsyme commented 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
Copy link
Contributor

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.

@OmarTawfik OmarTawfik removed their assignment Oct 6, 2016
@cartermp cartermp added this to the 16.0 milestone Aug 29, 2018
@cartermp cartermp added Feature Improvement and removed Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. Bug labels Oct 11, 2018
@cartermp cartermp modified the milestones: 16.0, Unknown Oct 11, 2018
@cartermp
Copy link
Contributor

Re-tagging issues and milestone as per duplicate issues.

@abelbraaksma
Copy link
Contributor

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
Copy link
Contributor

Please note that this applies both to the 'send to' and direct typing into fsi functionalities.

@dsyme
Copy link
Contributor

dsyme commented 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
Copy link
Contributor

@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
Copy link
Contributor

dsyme commented Oct 15, 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?

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
Copy link

pkese commented Aug 12, 2020

Similar problem...

I've tried if string interpolation (#8907) works in latest fsi.

dotnet fsi --langversion:preview

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

For help type #help;;

> let s = "world";;
val s : string = "world"

> $"Hello {s}";;

  $"Hello {s}";;
  ^^

/home/peterk/tmp/stdin(2,1): error FS1160: This token is reserved for future use

- ;;
- 
- 
- Interrupt
- #help;
- #help;;
-
-

...can't find a way to terminate input.

@dsyme dsyme added the Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language. label Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-VS-FSI VS window and commands for F# Interactive Feature Improvement Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.
Projects
Archived in project
Development

No branches or pull requests

8 participants