Skip to content

InvalidProgramException on string interpolation #17719

@bent-rasmussen

Description

@bent-rasmussen

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions