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

InvalidProgramException on string interpolation #17719

Closed
bent-rasmussen opened this issue Sep 13, 2024 · 3 comments · Fixed by #17722
Closed

InvalidProgramException on string interpolation #17719

bent-rasmussen opened this issue Sep 13, 2024 · 3 comments · Fixed by #17722

Comments

@bent-rasmussen
Copy link

Please provide a succinct description of the issue.

Repro steps

Provide the steps required to reproduce the problem:

  1. Create a console project with this code
type Foo() =

    let sb = System.Text.StringBuilder()

    member _.Bar(s: System.ReadOnlySpan<char>) = sb.Append(s) |> ignore

let foo = Foo()
let foos = "foo"
foo.Bar($"{foos} is bar")
  1. Build and run the project

Expected behavior

InvalidProgramException

Actual behavior

InvalidProgramException

Known workarounds

  • Use let binding for interpolated string and use that in function call
  • Use string instead of ReadOnlySpan<char>
  • Do not use string interpolation

Related information

Provide any related information (optional):

  • Windows 11
  • .NET 9 RC1
  • Version 17.12.0 Preview 2.0
@vzarytovskii
Copy link
Member

Yes, we should probably disallow byreflikes when we work with interpolation until we have good escape analysis.

@vzarytovskii
Copy link
Member

Also <LangVersion>8</LangVersion> fixes it

vzarytovskii added a commit to vzarytovskii/fsharp that referenced this issue Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants