Skip to content

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

@AvnonIdo

Description

@AvnonIdo

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

Metadata

Metadata

Assignees

Labels

Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

Type

No fields configured for Bug.

Projects

Status

New

Relationships

None yet

Development

No branches or pull requests

Issue actions