Skip to content

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

Closed

Description

@MaxWilson

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

Activity

  1. added this to the Backlog milestone on Feb 22, 2023
  2. added
    Area-VS-FSI
    Impact-Medium
    and removed on Feb 27, 2023
  3. PatrickSimpsonGFCMSU commented on Mar 17, 2023

    @PatrickSimpsonGFCMSU

    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.

  4. PatrickSimpsonGFCMSU commented on Mar 17, 2023

    @PatrickSimpsonGFCMSU

    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.

  5. vzarytovskii commented on Mar 17, 2023

    @vzarytovskii
    Member

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

  6. abonie commented on May 4, 2023

    @abonie
    Member

    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.

  7. theprash commented on May 4, 2023

    @theprash

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

  8. abelbraaksma commented on May 22, 2023

    @abelbraaksma
    Contributor

    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.

  9. moved this from Not Planned to Planned in F# Compiler and Toolingon Jun 1, 2023
  10. modified the milestones: Backlog, June-2023 on Jun 1, 2023
  11. jimfoye commented on Jun 12, 2023

    @jimfoye

    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.

  12. patrickallensimpson commented on Jul 11, 2023

    @patrickallensimpson

    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?

  13. vzarytovskii commented on Jul 12, 2023

    @vzarytovskii
    Member

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

    cc @KevinRansom

  14. patrickallensimpson commented on Jul 12, 2023

    @patrickallensimpson
  15. vzarytovskii commented on Jul 12, 2023

    @vzarytovskii
    Member

    Ah, probably wasn't inserted then.

  16. vzarytovskii commented on Jul 19, 2023

    @vzarytovskii
    Member

    Fixed in #15384

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area-VS-FSIBugImpact-MediumRegression

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions