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

FSI sometimes gets confused by tabs: "Unexpected symbol # in interaction. Expected incomplete structured construct at or before this point" #14779

Closed
MaxWilson opened this issue Feb 22, 2023 · 12 comments
Assignees
Labels
Area-VS-FSI VS window and commands for F# Interactive Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. Regression
Milestone

Comments

@MaxWilson
Copy link
Contributor

MaxWilson commented Feb 22, 2023

FSI sometimes gets confused by tabs.

Repro steps

  1. Open Microsoft (R) F# Interactive version 12.5.0.0 for F# 7.0

  2. Type in the following program

    let three() =
        3
  1. Highlight the second line (" 3") and Send to Interactive.

Expected behavior

FSI should evaluate and return 3.

Actual behavior

Error.

    System.IO.File.WriteAllText(@"C:\Users\wilso\AppData\Local\Temp\tmpE9F5.tmp.pid", string (System.Diagnostics.Process.GetCurrentProcess().Id));;
  ^

    stdin(1,1): error FS0010: Unexpected symbol # in interaction. Expected incomplete structured construct at or before this point, ';', ';;' or other token.

Known workarounds

Un-indent code before sending it to F# interactive.

let three() =
3

Related information

  • Operating system: Windows
  • .NET Runtime kind: Net Core 7.0
  • Editing Tools: VS 2022 17.6.0 Preview 1.0

screenshot

@github-actions github-actions bot added this to the Backlog milestone Feb 22, 2023
@0101 0101 added Regression Area-FSI Area-VS-FSI VS window and commands for F# Interactive Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. and removed Needs-Triage Area-FSI labels Feb 27, 2023
@PatrickSimpsonGFCMSU
Copy link

PatrickSimpsonGFCMSU commented Mar 17, 2023

I'm experiencing this same issue with VS 2022 Version 17.5.1 and 17.5.2 as well.

The code inside of methods that used to be able to be sent and executed that has any indentation now reports the following error:
System.IO.File.WriteAllText(@"C:\Users\psimp\AppData\Local\Temp\tmp4367.tmp.pid", string (System.Diagnostics.Process.GetCurrentProcess().Id));;
^

stdin(1,1): error FS0010: Unexpected symbol # in interaction. Expected incomplete structured construct at or before this point, ';', ';;' or other token.

Note It seems the additional code that is sent by VS to fsi that does not appear in the interactive console has a bug in it. I believe it might be related to the System.IO.File call since it shows an indent in front of the expression.

@PatrickSimpsonGFCMSU
Copy link

PatrickSimpsonGFCMSU commented Mar 17, 2023

This is also happening on:
Microsoft Visual Studio Community 2022 (64-bit) - Preview
Version 17.6.0 Preview 2.0

as well.

I was not able to revert back further than 17.5.1 but I know it was working 8 weeks ago or so.

@vzarytovskii
Copy link
Member

vzarytovskii commented Mar 17, 2023

Yeah, I still see it on latest main cc @KevinRansom

@abonie
Copy link
Member

abonie commented May 4, 2023

Just FYI, selecting from a first (non-whitespace) character in the first line of selection seems like a good workaround:
image
Selecting from the beginning of a line still gives the same error, so it still needs fixing.

@theprash
Copy link

theprash commented May 4, 2023

@abonie That workaround only works if you're selecting one item at that indentation level. If you selected two items it would give an error. For example with this code:

    let f() =
        ()
    let g() =
        ()

If you select both functions but only from the first let, what you're actually sending to FSI is this code which doesn't compile because the indentation is off:

let f() =
        ()
    let g() =
        ()

The only actual workaround I know is to temporarily unindent all of the code so it starts at column 1, select it, send it to FSI and undo the indentation. It's really awkward.

@abelbraaksma
Copy link
Contributor

abelbraaksma commented May 22, 2023

This is a relatively recent bug. I was a little bit behind on updating VS and F# locally, but now I'm experiencing the same behavior. As others have already mentioned, it is a really confusing and annoying error, and non-trivial to work around.

Also of note, I lose the prompt and it doesn't come back.

@jimfoye
Copy link

jimfoye commented Jun 12, 2023

So, I think everyone realizes this, but just to clarify, the problem is any indentation, not just tabs. The issue title should probably be changed.

This was referenced Jun 13, 2023
@patrickallensimpson
Copy link

patrickallensimpson commented Jul 11, 2023

When will this actually show up in a Visual Studio preview? 17.7 preview 3 was release today and this still doesn't work.
Is there a way to know what fsharp releases are going into a VS preview release?

Is there a way to build the VS integration and side load it into VS would that be in the contributor section?

@vzarytovskii
Copy link
Member

The fix should have been in p3, not sure why it still shows

cc @KevinRansom

@patrickallensimpson
Copy link

patrickallensimpson commented Jul 12, 2023 via email

@vzarytovskii
Copy link
Member

Ah, probably wasn't inserted then.

@vzarytovskii
Copy link
Member

Fixed in #15384

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 Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. Regression
Projects
Archived in project
Development

No branches or pull requests

10 participants