Skip to content

Reject non-function bindings for single-case and partial active pattern names#19763

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-active-pattern-definition
Draft

Reject non-function bindings for single-case and partial active pattern names#19763
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-active-pattern-definition

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 18, 2026

The compiler previously rejected non-function multi-case active patterns ((|A|B|)) but still allowed equivalent invalid forms for single-case ((|A|)) and partial ((|A|_|)) names. This left declarations that tooling recognized as active patterns but could not be used in pattern positions.

  • Checker behavior aligned across active pattern forms

    • Updated post-inference active-pattern validation to run the function-typed check for all active pattern bindings, not only multi-case ones.
    • This makes FS1209 (Active pattern '...' is not a function) consistently apply to single-case and partial declarations as well.
  • Conformance coverage expanded

    • Extended E_ActivePatternNotAFunction.fs with explicit single-case and partial non-function declarations.
    • Updated expected diagnostics in Named.fs to assert all three FS1209 errors.
  • Example of newly-rejected declarations

    let (|C|) = 3
    let (|D|_|) = None
    // now reported as FS1209: Active pattern '...' is not a function

Copilot AI changed the title [WIP] Fix compiler allowing non-functions as active pattern names Reject non-function bindings for single-case and partial active pattern names May 18, 2026
Copilot finished work on behalf of T-Gro May 18, 2026 12:23
Copilot AI requested a review from T-Gro May 18, 2026 12:23
The PR's new validation rejects non-function active pattern bindings for
single-case and partial patterns (extending the existing multi-case check).
The RelaxWhitespace2.fs test file had several active patterns defined as
non-function values (|C|, |F|_|, |G|_|, etc.) since it tests whitespace
relaxation, not active pattern semantics.

Add parameters to make these active patterns function-typed while preserving
the multiline whitespace structure being tested.

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

github-actions Bot commented May 19, 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

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

Compiler allows non-functions to be bound to active pattern names

2 participants