Copy and update inside a folder function with an anonymous record prints a misleading error message
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
When using an anonymous record as the initial state of a fold, I noticed that I can't use copy and update expressions in the folder function. See this screenshot:

After a bit of troubleshooting on the FSSF Slack server, we noticed that the anonymous record has to be constructed "fully" once, and then the copy and update syntax is available.

Code snippet:
```f#
type Command =
| Add of int
| Sub of int
let anonymousRecordFoldMatchBug x =
let commandList = [Add 3; Sub 1; Add 10]
commandList
|> List.fold (fun state value ->
match value with
| Add x -> {| Result = state.Result + x |}
| Sub x -> {| state with Result = state.Result + x |})
{| Result=0 |}
```
**Expected behavior**
Being able to use the copy and update syntax from the start, or at least a more explicative error message that points out the steps needed to fix the problem.
Contributor guide
Assessment
This issue has not been assessed yet.