A student encountered this bug. When she hits Ctrl-A (select all) followed by Alt-Enter (FSI: send selection) chunks of her code aren't sent to FSI.
Ubuntu 16.04.1 LTS
Visual Studio Code 1.8.1
ionide-fsharp 2.19.5
F# version: 4.0.0.4+dfsg2-2 from the xenial/universe Ubuntu repo
Source file that triggers the bug
Error message snippet
I can repro this easily on the student's machine, but not on my Windows machine.
@Krzysztof-Cieslak mentions the possibility that this might be VS Code-side. I'm inclined to agree.
More info available upon request, just let me know what you need and I'll try to get it.
I was just able to reproduce the bug as well on an Ubuntu 14.04 machine.
Ubuntu 14.04.5 LTS
VS Code 1.8.1
ionide-fsharp 2.19.5
F# version: 4.0.0.3-0xamarin1 from the http://download.mono-project.com/repo/debian/ repo
When I select all the code from that gist, I get the first 472 bytes of the code, which is immediately followed by the last 574 bytes of the code. The middle 512 bytes are left out. In other words, in the middle of the code snippet that FSI receives is the following:
let rec pairlists twolists =
match twolists with
| ([], []) -> []
| ([],x::xs) -> failwith "Error -- lists are not of the same atch lst with
| [] -> []
| x::xs -> if item <> x then x::remove(item, xs) else remove(item, xs)
(* Question 3. *) (* Do not edit this line. *)
Note that if I start the FSI server (by hitting F1 and running the FSI: Start command) before sending the text, this bug doesn't trigger. The entire text is sent correctly to FSI.
Also, if I set the FSharp.legacyFSI setting to true, the bug also doesn't trigger: the entire text is sent correctly.
Only when FSharp.legacyFSI is false and the FSI server hasn't yet been started will there be a missing chunk of 512 bytes in the middle of the sent text.
Something else that's interesting: the fact that the first 472 bytes of the code (up to the string "lists are not of the same " with trailing space) are successfully received... appears to not be random. Because those bytes are preceded by the following text:
# silentCd @".";;
# 1 @"Untitled-1"
;;
Counting the invisible trailing space after "Untitled-1" (which comes from line 33 of Fsi.fs), that's 40 bytes. 40 bytes of prefix plus 472 bytes of successfully-received code = 512 bytes.
Note that the student's code was broken in a different place than mine, because the path and filename sent to F# via the # silentCd and # 1 directives were different. (In my reproduction, I created a new unnamed file, set the file type to F# so that Alt+Enter would work, and sent it -- so the editor had no filename and the title was "Untitled-1". The student's code had a filename of "assignment1.fs" and a different path, hence why the preamble was a different length. But I bet if you calculated the length of the # silentCd + # 1 preamble that lilred's student would have been sending, plus the length of the successfully-received code in the Gist of the error message, it would also add up to 512 bytes.
So we have 512 bytes successfully received, then 512 bytes dropped, then the rest of the code successfully received. Those numbers don't look like a coincidence to me.
UPDATE: I just looked at the Error message snippet Gist that @lilred posted. From that snippet, I was able to calculate the number of dropped bytes, and it was 256, not 512. (It sent the line match twolists with, then the line | ([], []) -> [], then one space of the next line -- and the next character you see is the tail end of the let c = common([3;4;5;7;2], [1;3;5;7;1])*) line. Pasting the omitted bytes into a file and counting them (making sure not to add a trailing newline), I discovered that exactly 256 bytes had been left out. I was also able to reproduce what would have been sent in lilred's bug repro, and it looks like the successful portion of the sent code might have been 512 bytes as well.
It's looking like the input sent to FSI is being sent in 256-byte chunks, and there's a brief window during startup where the FSI process just drops input chunks on the floor instead of processing them.
Cab you try to reproduce it on latest VSCode version?
This is pretty easy for me to reproduce funkiness, I don't know if this is related or the exact same issue. This is the latest VSCode/ionide running on a Mac
1 * 5)Lots of fun stuff happens
# silentCd @".";;
# 1 @"Untitled-1"
;;
1 * 5;;
;;
1 * 5;;
;;
F# Interactive for F# 4.1
Freely distributed under the Apache 2.0 Open Source License
For help type #help;;
> # silentCd @".";;
- # 1 @"Untitled-1"
- ;;
>
- 1 * 5;;
val it : int = 5
> ;;
>
- 1 * 5;;
val it : int = 5
> ;;
> ^?^?^?^?^?^?^?^?
That ^?^?^?^?^? is now in the input prompt area, so the next command you run will try to execute it,
which leads to
Untitled-1(8,1): error FS0010: Unexpected character '' in interaction
@onionhammer what you bring up is a different issue, and it has a decent workaround - simply disable flowcontrol in VS Code user preferences.
Ahh, appreciated
So, can anyone reproduce it using latest VSCode and Ionide?
Still seems to be happening on my machine with VS Code 1.9.1 and Ionide-fsharp 2.23.5; I don't think the bug is solved quite yet.
I would check with @SoftwareApe what the chunk size is (see #199), I think bringing it down to 256 bytes might fix this bug too.
@lilred I put the chunk size at 256 characters in Issue #199, it just seemed like a round number, that definitely wouldn't hit the fuzzy character limit on #199. I guess if this doesn't work yet, 2.23.1+ then the chunking doesn't solve the issue.
I can't reproduce this bug on my machine. I'm on a Windows machine though.
Like @rmunn, I can still reproduce this on 2.23.5. I'm on VS Code 1.8.1. So chunking doesn't fix.
Yeah I'm still able to reproduce this as well. Also there is no 'flowcontrol' preference anymore?
I think flowcontrol got removed completely.
Can you also check on latest insider? I know that VSCode Team fixed some stuff that may have caused it.
I experienced a similar issue that i logged at https://stackoverflow.com/questions/48695225/fs0010-unexpected-keyword-in-binding?noredirect=1#comment84395743_48695225
All. I have the very latest version of Code (1.25.1), version 3.22.3 of Ionide, and I am experiencing the same issue as kgreed above. Even if I have just two lines, e.g.
let sampleFunction3 x =
if x < 100.0 then
2.0*x*x - x/5.0 + 3.0
else
2.0*x*x + x/5.0 - 37.0
let result3 = sampleFunction3 (6.5 + 4.5)
let result4 = sampleFunction3 54.0
Pressing Alt+Enter, I get the same error, namely,
_BasicFunctions.fsx(3,5): error FS0010: Unexpected keyword 'let' or 'use' in binding. Expected incomplete structured construct at or before thi_
I have seen other people using Code in the same way without issue, so something is not quite right somewhere?