Skip to content

Avoid false FS1113 on inline instance members with class-scope self identifiers#19761

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-fs1113-error-class-scope
Draft

Avoid false FS1113 on inline instance members with class-scope self identifiers#19761
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-fs1113-error-class-scope

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 18, 2026

Inline instance members in classes currently fail with FS1113 when a class-scope self identifier is present (type C() as self = ...), even though the member body is valid. This change removes that false-positive path while preserving FS1113 behavior for non-member inline values.

  • Compiler behavior change (Optimizer)

    • Updated inline-completeness enforcement to apply only to non-member values.
    • CheckInlineValueIsComplete now skips the IsPartialExprVal/FS1113 check when v.IsMember is true.
  • Regression coverage (ComponentTests)

    • Added a focused test in MemberDeclarations covering the three reported forms:
      • class-scope self + different member self identifier
      • class-scope self + same member self identifier
      • class-scope self + _ member self identifier
type TestClass1() as SomeSelfIdentifier =
    member inline AnotherSelfIdentifier.test() = 5

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

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

Copilot AI changed the title [WIP] Fix FS1113 error with inline member in class scope Avoid false FS1113 on inline instance members with class-scope self identifiers May 18, 2026
Copilot finished work on behalf of T-Gro May 18, 2026 12:34
Copilot AI requested a review from T-Gro May 18, 2026 12:34
Copy link
Copy Markdown
Member

@T-Gro T-Gro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is correct. Class-scope self identifiers (as self) produce UnknownValue in the optimizer representation, causing spurious FS1113 for inline members. Skipping the check for all members via not v.IsMember is sound because:

  1. Accessibility for inline members is already enforced by FS0044 at type-check time
  2. Partial optimizer data for members is expected (self-parameter handling) and doesn't indicate a broken inline
  3. The internal error at line 4217 still guards against truly unresolvable inline data

The test covers the three reported forms cleanly. LGTM.

@T-Gro T-Gro added the AI-reviewed PR reviewed by AI review council label May 20, 2026
@T-Gro T-Gro self-requested a review May 20, 2026 12:48
@github-actions
Copy link
Copy Markdown
Contributor

❗ Release notes required

@copilot,

Caution

No release notes found for the changed paths (see table below).

Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format.

The following format is recommended for this repository:

* <Informative description>. ([PR #XXXXX](https://github.com/dotnet/fsharp/pull/XXXXX))

See examples in the files, listed in the table below or in th full documentation at https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html.

If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

You can open this PR in browser to add release notes: open in github.dev

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.100.md No release notes found or release notes format is not correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-reviewed PR reviewed by AI review council

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

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

2 participants