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

F#: Allow triple-quoted strings to interpolate string literals (.NET 5 feature) #21

Closed
rdipardo opened this issue Jul 28, 2021 · 0 comments
Labels
fsharp Caused by the fsharp (F#) lexer

Comments

@rdipardo
Copy link
Contributor

Since the release version 5.0, F# handles interpolated strings with as much facility as C# has done for years.

Lexilla's F# lexer doesn't yet recognize all the potential use cases of this new language feature.

In particular, a triple-quoted string may be prefixed with the $ interpolation sigil; this is the only way to interpolate a value that is itself a string literal ℹ️ :

> $"""Date: {System.DateTime.Now.ToString("yyyy-MM-dd")}""" ;;
val it : string = "Date: 2021-07-28"

The internal string should not interrupt the surrounding style region; but that's currently not the case:

pre-patch-interpolated-string-literals png

This patch set implements and tests interpolated string literals in the above context:


ℹ️

> $"Date: {System.DateTime.Now.ToString("yyyy-MM-dd")}" ;;

  $"Date: {System.DateTime.Now.ToString("yyyy-MM-dd")}" ;;
  --------------------------------------^

stdin(2,39): error FS3373: Invalid interpolated string. Single quote or verbatim string literals may not be used in interpolated expressions in single quote or verbatim strings. Consider using an explicit 'let' binding for the interpolation expression or use a triple quote string as the outer string literal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fsharp Caused by the fsharp (F#) lexer
Projects
None yet
Development

No branches or pull requests

2 participants