-
Notifications
You must be signed in to change notification settings - Fork 787
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
Comments
Please check the F# language spec - string literals in comments are parsed as string literals. This allows for commenting-out of code involving 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 |
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:
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. |
Re-tagging issues and milestone as per duplicate issues. |
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. |
Please note that this applies both to the 'send to' and direct typing into fsi functionalities. |
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? |
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. |
Similar problem... I've tried if string interpolation (#8907) works in latest fsi.
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. |
See https://twitter.com/eiriktsarpalis/status/679692748182663168 for a reproduction.
The text was updated successfully, but these errors were encountered: