Skip to content

FS3868 incorrectly triggered for parameterized active patterns in F# 9 #18638

Closed
@brandedoutcast

Description

@brandedoutcast

In F# 8 / .NET 8, parameterized active patterns defined as (|Pattern|_|) p = function ... compile and work correctly. In F# 9 / .NET 9, the same code fails with FS3868, incorrectly assuming the active pattern has no parameters.

This is either a breaking change or a bug, and it’s not documented in the F# 9 release notes.

let rec parse p =
    function
    | IsSomething p v -> Some v
    | _ -> None

and (|IsSomething|_|) p =
    function
    | "nested" -> parse p "42"
    | "42" -> Some 42
    | _ -> None

Expected behavior

Parameterized active patterns written using (|Pattern|_|) p = function ... should continue to compile, or the change should be documented explicitly as breaking.

Actual behavior

Parameterized active patterns written using (|Pattern|_|) p = function ... fails with FS3868, incorrectly assuming the active pattern has no parameters.

Known workarounds

let rec parse p =
    function
    | IsSomething p v -> Some v
    | _ -> None

and (|IsSomething|_|) p input =
    match input with
    | "nested" -> parse p "42"
    | "42" -> Some 42
    | _ -> None

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions