Skip to content

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

Open

Description

Activity

  1. 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[/+] on Dec 23, 2015
  2. dsyme commented on Jan 8, 2016

    @dsyme
    Contributor

    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

  3. 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[/+] on Jan 8, 2016
  4. added
    Area-VS-FSI
    on Jan 8, 2016
  5. eiriktsarpalis commented on Jan 12, 2016

    @eiriktsarpalis
    MemberAuthor

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

  6. added
    Impact-Medium
    on Jan 12, 2016
  7. OmarTawfik commented on Mar 2, 2016

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

  8. dsyme commented on Mar 4, 2016

    @dsyme
    Contributor

    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.

  9. OmarTawfik commented on Oct 6, 2016

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

  10. removed their assignment
    on Oct 6, 2016
  11. added this to the 16.0 milestone on Aug 29, 2018
  12. added and removed
    Impact-Medium
    on Oct 11, 2018
  13. 4 remaining items

  14. abelbraaksma commented on Oct 11, 2018

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

  15. abelbraaksma commented on Oct 11, 2018

    @abelbraaksma
    Contributor

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

  16. dsyme commented on Oct 12, 2018

    @dsyme
    Contributor

    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

  17. abelbraaksma commented on Oct 12, 2018

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

  18. dsyme commented on Oct 15, 2018

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

    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.

  19. pkese commented on Aug 12, 2020

    @pkese

    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.

  20. added
    Theme-Simple-F#
    on Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-VS-FSIFeature ImprovementTheme-Simple-F#

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions