Skip to content

Specialize FS0027 for function/method parameters#19866

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

Specialize FS0027 for function/method parameters#19866
T-Gro wants to merge 4 commits into
mainfrom
fix/issue-15803

Conversation

@T-Gro
Copy link
Copy Markdown
Member

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

Summary

When the assignment target in FS0027 is a function or method parameter, the compiler now emits a parameter-specific error message suggesting legal remediations (\let mutable x = x\ shadow or \�yref<_>) instead of the illegal \let mutable x = expression\ suggestion.

Local \let\ bindings retain the original message.

Changes

  • CheckIncrementalClasses.fs: Tag parameter bindings so the error path can distinguish them from local lets.
  • CompilerDiagnostics.fs: Emit a specialized FS0027 message for parameters.
  • FSStrings.resx / xlf files: New resource string for the parameter-specific message.
  • Tests: New \AssignmentToParameterErrorTests.fs\ component tests covering both parameter and local-let scenarios.
  • Release notes: Entry in \11.0.100.md.

Fixes #15803

Copilot and others added 3 commits May 29, 2026 18:26
Tests pin the desired behavior: FS0027 emitted on a parameter must not
suggest the illegal 'let mutable x = expression' shadow. Local-let
behavior preserved as regression sentinel.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When the assignment target is a parameter, emit a message that suggests a legal remediation ('let mutable x = x' shadow, or byref<_>) instead of the illegal 'let mutable x = expression'. Local 'let' bindings retain the original message.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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

github-actions Bot commented May 29, 2026

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.100.md

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

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Don't suggest using mutable keyword for parameters

1 participant