-
Notifications
You must be signed in to change notification settings - Fork 830
Closed
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone
Description
Trying to use static interface members feature in a hierarchy of interfaces leads to a compiler error that looks like a bug.
Repro steps
Try to compile following module with F# 7 (SDK 7.0.100)
module StaticAbstractMemberBug
#nowarn "3535"
type IParseable<'T when 'T :> IParseable<'T>> =
static abstract member Parse : string -> 'T
type IAction<'T when 'T :> IAction<'T>> =
inherit IParseable<'T>
type SomeAction =
| A
| B
with
interface IAction<SomeAction> with
static member Parse (s: string) : SomeAction =
match s with
| "A" -> A
| "B" -> B
| _ -> failwith "can't parse"
Expected behavior
Code compiles successfully.
Actual behavior
FSC : error FS2014: A problem occurred writing the binary 'obj\Debug\net7.0\refint\FSharpConsoleApp1.dll': Error in pass3 for type StaticAbstractMemberBug, error: Error in pass3 for type SomeAction, error: Error in GetMethodRefAsMethodDefIdx for mref = ("StaticAbstractMemberBug.IParseable<StaticAbstractMemberBug.SomeAction>.Parse",� "SomeAction"), error: MethodDefNotFound
Known workarounds
Move static abstract member to the top-level interface:
#nowarn "3535"
type IAction<'T when 'T :> IAction<'T>> =
static abstract member Parse : string -> 'T
type SomeAction =
| A
| B
with
interface IAction<SomeAction> with
static member Parse (s: string) : SomeAction =
match s with
| "A" -> A
| "B" -> B
| _ -> failwith "can't parse"
Related information
- Windows
- .net 7 SDK 7.0.100
- reproduces both in Visual Studio or Rider
anpin
Metadata
Metadata
Assignees
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Type
Projects
Status
Done