"as" pattern with an identifier picks a literal
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 144
Description
There has been a [change](https://github.com/fsharp/fslang-design/blob/main/FSharp-6.0/FS-1105-Non-variable-patterns-to-the-right-of-as-patterns.md) 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**
```fs
[]
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.
Environment: https://sharplab.io/#v2:DYLgZgzgPg2gPAGQJYBcCmAnAhsAfAXQFgAoYNFAAgGEB7CgXgoCYSBbLFAYwAsKBGCgHdU3ElH4UsEanQC0uCgAcMSAHYowFAER8tYigH0K8pSvWatNFN0xagA=
Trying this in an [older version of the compiler](https://tryfsharp.fsbolero.io/) exhibits the expected behaviour.
Contributor guide
Assessment
This issue has not been assessed yet.