Skip to content

Illegal syntax in an active pattern produces an internal compiler error #5745

@misterspeedy

Description

@misterspeedy

Description: A specific kind of incorrect syntax in an active pattern definition causes an internal compiler error rather than a message specific to the error.

Repro Steps: Add the following code:

open System.Text.RegularExpressions

let (|USZipPlus4Code|_|) s =
    let m = Regex.Match(s, @"^(\d{5})\-(\d{4})$")
    if m.Success then
        USZipPlus4Code(x=m.Groups.[1].Value, 
                       y=m.Groups.[2].Value)
        |> Some
    else
        None

Expected: An error along the lines of:

'Active pattern bindings do not support field names.'

Actual:

'error FS0073: internal error: impossible (Failure)'

Severity: minor.

Version: F# 4.5

Workaround: Use correct active pattern syntax. In this case, omit the x= and y=.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions