You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reject static abstract member invocations on F# interface types (fixes#19231) (#19232)
Extend the pattern match in ConstraintSolver.fs to also reject FSMeth when
it represents a static abstract interface member being called directly on
the interface type.
The check handles FSMeth case alongside ILMeth:
- Not a constrained call via type parameter
- Not an instance member (i.e., static)
- Is on an interface type
- Is a dispatch slot member (abstract)
Uses the same error message 3866 (chkStaticAbstractInterfaceMembers).
Copy file name to clipboardExpand all lines: docs/release-notes/.FSharp.Compiler.Service/11.0.0.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@
16
16
* Fix insertion context for modules with multiline attributes. ([Issue #18671](https://github.com/dotnet/fsharp/issues/18671))
17
17
* Fix `--typecheck-only` for scripts stopping after processing `#load`-ed script ([PR #19048](https://github.com/dotnet/fsharp/pull/19048))
18
18
* Fix object expressions in struct types generating invalid IL with byref fields causing TypeLoadException at runtime. ([Issue #19068](https://github.com/dotnet/fsharp/issues/19068), [PR #19070](https://github.com/dotnet/fsharp/pull/19070))
19
+
* Reject direct invocation of static abstract interface members on F#-defined interface types, which caused BadImageFormatException at runtime. ([Issue #19231](https://github.com/dotnet/fsharp/issues/19231), [PR #19232](https://github.com/dotnet/fsharp/pull/19232))
Copy file name to clipboardExpand all lines: tests/FSharp.Compiler.ComponentTests/Conformance/Types/TypeConstraints/IWSAMsAndSRTPs/IWSAMsAndSRTPsTests.fs
+43Lines changed: 43 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1752,3 +1752,46 @@ printfn "Success: %d" result
1752
1752
|> compileAndRun
1753
1753
|> shouldSucceed
1754
1754
1755
+
// Tests for issue #19231: Invoking static abstract member on interface type should be rejected
|> withSingleDiagnostic (Error 3866, Line l1, Col c1, Line l2, Col c2, $"A static abstract non-virtual interface member should only be called via type parameter (for example: 'T.{memberName}).")
1765
+
1766
+
[<FactForNETCOREAPP>]
1767
+
let``SRTP call to static abstract via type parameter succeeds`` ()=
1768
+
Fsx "type IP = static abstract Parse : string -> int\ntype P() = interface IP with static member Parse s = int s\nlet inline p<'T when 'T :> IP> s = 'T.Parse s\nif p<P> \"42\" <> 42 then failwith \"fail\""
0 commit comments