Skip to content

Fix ICE on named-arg indexer setter (#16034)#19851

Open
T-Gro wants to merge 4 commits into
mainfrom
fix/issue-16034
Open

Fix ICE on named-arg indexer setter (#16034)#19851
T-Gro wants to merge 4 commits into
mainfrom
fix/issue-16034

Conversation

@T-Gro
Copy link
Copy Markdown
Member

@T-Gro T-Gro commented May 28, 2026

Summary

Fixes #16034 — calling an indexed property setter with a named argument (e.g. .indexed1(a1="ok") <- 1) caused an internal compiler error (FS0193 / ArgumentException: The input must be non-negative).

Root Cause

When a named argument matches one of the indexer arguments of a property setter, the remaining unnamed called args may number fewer than 2. The ParamArray detection in MethodCalls.fs used
UnnamedCalledArgs - 2 unconditionally for indexer setters, leading to a negative index into calledArgs.

Fix

  • Gate the setter-shape indexing on
    UnnamedCalledArgs >= 2 and fall back to the regular path otherwise.
  • Skip the unnamed-arg-prefix deprecation check for indexer setters, since the trailing 'value' arg breaks the strict (i, j) position match when an indexer arg is supplied by name.
  • Fix a minor issue in ConstraintSolver.fs where a property-setter indexer arg count was off-by-one.

Tests

Added IndexedSetterNamedArgTests.fs covering:

  • Single-index setter with named arg
  • Multi-index setter with one named arg
  • Named �alue arg on setter
  • Extension-method indexed setter with named arg

All variants compile and typecheck without error.

Copilot and others added 3 commits May 28, 2026 15:17
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a named argument matches one of the indexer arguments of a property setter, the remaining unnamed called args may number fewer than 2. The ParamArray detection used nUnnamedCalledArgs-2 unconditionally for indexer setters, leading to a negative index and FS0193. Gate the setter-shape indexing on nUnnamedCalledArgs >= 2 and fall back to the regular path otherwise. Also skip the unnamed-arg-prefix deprecation check for indexer setters, since the trailing 'value' arg breaks the strict (i,j) position match when an indexer arg is supplied by name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

❗ Release notes required

@T-Gro,

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

@github-actions github-actions Bot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label May 28, 2026
@T-Gro T-Gro requested a review from abonie May 29, 2026 11:08
@T-Gro T-Gro enabled auto-merge (squash) May 29, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

SNAFU with indexed properties & type extensions: internal error & inconsistency over shadowing

1 participant