Skip to content

[Python] unit function (zero arguments functions) are transpiled inconsistently #4126

@x-EricH-x

Description

@x-EricH-x

Description

The following F# code

open Fable.Core

[<AttachMembers>]
type Foo(zeroArgFunc) =
    member this.ZeroArgMethod() = zeroArgFunc()

is transpiled to

from __future__ import annotations
from collections.abc import Callable
from typing import Any
from fable_library_js.reflection import (TypeInfo, class_type)

def _expr2() -> TypeInfo:
    return class_type("Test.Foo", None, Foo)


class Foo:
    def __init__(self, zero_arg_func: Callable[[], Any]) -> None:
        self.zero_arg_func: Callable[[], Any] = zero_arg_func

    def ZeroArgMethod(self, __unit: None=None) -> Any:
        this: Foo = self
        return this.zero_arg_func(None)


Foo_reflection = _expr2

def Foo__ctor_3689BAF1(zero_arg_func: Callable[[], Any]) -> Foo:
    return Foo(zero_arg_func)

the zero_arg_func is typed as Callable[[], Any] but being passed a None as arg at the same time

  • self.zero_arg_func: Callable[[], Any] = zero_arg_func
  • return this.zero_arg_func(None)

Tooling info

https://fable.io/repl/
REPL: 4.2.0
Fable: 4.23.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions