Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F# 7 static abstract member inherited from base interface - "error in pass3" bug #14595

Closed
DunetsNM opened this issue Jan 12, 2023 · 2 comments · Fixed by #16195
Closed

F# 7 static abstract member inherited from base interface - "error in pass3" bug #14595

DunetsNM opened this issue Jan 12, 2023 · 2 comments · Fixed by #16195
Assignees
Labels
Area-Compiler-CodeGen IlxGen, ilwrite and things at the backend Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone

Comments

@DunetsNM
Copy link

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
@github-actions github-actions bot added this to the Backlog milestone Jan 12, 2023
@vzarytovskii vzarytovskii added Area-Compiler-CodeGen IlxGen, ilwrite and things at the backend Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. and removed Needs-Triage labels Jan 12, 2023
@vzarytovskii vzarytovskii self-assigned this Jan 12, 2023
@anpin
Copy link

anpin commented Jul 26, 2023

Also reproduces with dotnet build on .NET SDK Version: 7.0.304 Commit: 7e794e2806

@gusty
Copy link
Contributor

gusty commented Oct 30, 2023

Closed by #16195

@vzarytovskii vzarytovskii linked a pull request Oct 30, 2023 that will close this issue
@github-project-automation github-project-automation bot moved this from Future to Done in F# Compiler and Tooling Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compiler-CodeGen IlxGen, ilwrite and things at the backend Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants