Skip to content

Signature generation roundtrip issue: SRTP multi-witness constraint on type member #19594

Closed

Description

@T-Gro

Implementation:

module Lib

let inline RequireM< ^Witnesses, ^T 
    when (^Witnesses or ^T): (static member M : ^T -> string)> (x: ^T) : string = 
    ((^Witnesses or ^T): (static member M : ^T -> string) x)

type C(p:int) = 
    member x.P = p

type Witnesses() =
    static member M (x: C) : string = sprintf "M(C), x = %d" x.P
    static member M (x: int64) : string = sprintf "M(int64), x = %d" x

type StaticMethods =
    static member inline M< ^T when (Witnesses or ^T): (static member M: ^T -> string)> (x: ^T) : string =
        RequireM< Witnesses, ^T> (x)

Actual generated signature (partial):

val inline RequireM:
  x: ^T -> string when (^Witnesses or ^T) : (static member M: ^T -> string)
...
type StaticMethods =
    static member
      inline M: x: ^T -> string
                  when (Witnesses or ^T) : (static member M: ^T -> string)

Note: RequireM uses ^Witnesses (hat). StaticMethods.M uses Witnesses (no hat). Should be ^Witnesses.

Error on roundtrip compile:

error FS0340: The signature and implementation are not compatible because the declaration of the type parameter requires a constraint of the form (^Witnesses or ^T) : (static member M: ^T -> string)

Expected signature:

[<Class>]
type StaticMethods =
    static member inline M< ^T when (Witnesses or ^T) : (static member M: ^T -> string)> : x: ^T -> string

Verified: roundtrips successfully with explicit type param syntax.

Activity

  1. self-assigned this
    on Apr 15, 2026
  2. added
    Area-Compiler-SigFileGen
    on Apr 15, 2026
  3. added this to the Backlog milestone on Apr 15, 2026
  4. T-Gro commented on Apr 17, 2026

    @T-Gro
    MemberAuthor

    Additional repro found by corpus sweep (also fixed by this change):

    // impl
    module Pos34
    [<Sealed>]
    type Foo<'bar>() =
        member inline _.Baz<'a> (x: 'a) = x

    Before fix, generated sig had type application syntax that failed to parse (FS0010). The explicit type param declaration fix resolves this as well.

  5. added 3 commits that reference this issue on Apr 17, 2026
    8325bc8
    6d58f79
    b639193
  6. added a commit that references this issue on Apr 28, 2026
    6916ab1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area-Compiler-SigFileGenBugNeeds-Triage

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions