Skip to content

abstract static member invocation (still) not working in JS #3829

@DunetsNM

Description

@DunetsNM

Description

It's claimed in Fable 4.18.0 release notes that static interfaces are now supported however my code still fails to compile to JS.

Repro code

It's simplified version of #3822 I reported before (claimed to be fixed by 4.18.0 but it's actually not), you can try to run it in https://fable.io/repl/

type AbstractId<'ImplId when 'ImplId :> AbstractId<'ImplId>> =
    static abstract member Parse: idStr: string -> 'ImplId

type MyId = MyId of int
with 
  interface AbstractId<MyId> with
    static member Parse (idStr: string) =
        System.Int32.Parse idStr |> MyId

let inline parse<'ImplId when 'ImplId :> AbstractId<'ImplId>> (idStr: string) : 'ImplId =
    'ImplId.Parse idStr

printfn "Id constructed: %A" (MyId 1234)
printfn "Id parsed: %A" (parse<MyId> "1234")

Expected and actual results

Expected

Code outputs

Id constructed: MyId 1234
Id parsed: MyId 1234

Just like it does in LINQPad, for example:

image

Actual

It fails to compile. Note that it passes F# compilation step but fails further translation to JS

image

Related information

If I comment out last line it compiles and runs fine:

image

  • Fable version: 4.18.0
  • OS: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions