fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Error FS1113 when creating a class with a class scope self-identifier and an inline member

Open AvnonIdo opened this issue 1 year ago • 0 comments

Repro steps The following code can easily reproduce the error:

type TestClass() as SomeSelfIdentifier =
    member inline AnotherSelfIdentifier.test() = 5

It also happens when the self-identifier is the same:

type TestClass() as self =
    member inline self.test() = 5

And even when using '_' for the member-scope self-identifier:

type TestClass() as self =
    member inline _.test() = 5

Expected behavior

Successful build

Actual behavior

The build fails with the following error: "Error FS1113 : The value 'test' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible"

Known workarounds

Either make the inline function external and receive the instance as an argument or rework every 'let' that needs the class-scope self-identifier to be a member that uses a function-scoped self-identifier instead.

Related information

I needed an inline function for a member constraint in my real use case. It worked perfectly until I added the self-identifier for use in some other function.

  • Operating system Windows 10
  • .NET Runtime kind (.NET Core, .NET Framework, Mono) .NET 8.0
  • Editing Tools (e.g. Visual Studio Version, Visual Studio) Rider

AvnonIdo avatar Oct 19 '24 08:10 AvnonIdo