Description
There has been a change in F# 6 that introduces arbitrary patterns to the right of as
. However, this is also a breaking change in case an identifier is used that starts with an uppercase letter, which was an already valid syntax before F# 6 to create a new variable.
Repro steps
[<Literal>]
let Co = 2
match 1 with
| 1 as Co -> printf "1"
| _ -> printf "other"
Expected behavior
The match should succeed, bind 1
to a new variable Co
, and print "1".
Actual behavior
"other" is printed, since it interprets the first pattern as 1 as 2
.
Known workarounds
Not using identifiers after as
that start on an uppercase letter.
Related information
I am not sure if this behaviour is by design or not, since the RFC that introduces it does not discuss this case. However, I believe it is not by design, since the feature is marked as not being a breaking change. If the breaking change stays in, warnings should be issued since the interpretation of the code differs.
Trying this in an older version of the compiler exhibits the expected behaviour.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status