Skip to content

Can't compile static abstract member functions with byref parameters #18135

Open
@nodakai

Description

@nodakai

FSC : error FS2014: A problem occurred writing the binary 'obj/Debug/net9.0/refint/Sandbox0.dll': Error in pass3 for type Program, error: Error in pass3 for type T, error: Error in GetMethodRefAsMethodDefIdx for mref = ("Program.I.Foo", "T"), error: MethodDefNotFound

Repro steps

[<Interface>]
type I =
  static abstract Foo: int inref -> int

type T =
  interface I with
    static member Foo i = i

let f<'T when 'T :> I>()  =
  let x = 123
  printfn "%d" ('T.Foo &x)

f<T>()

Expected behavior

This should compile fine

Actual behavior

Weird error quoted above

Known workarounds

Replace byref parameters with Span<T>

Related information

dotnet --version
9.0.100

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions