Struct member access inside quotation gives compile error
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 144
Description
Acccessing members of a _struct_ captured local variable gives spurious "A quotation may not involve an assignment to or taking the address of a captured local variable" errors.
#### Repro steps
```fsharp
open FSharp.Quotations
[]
type S =
{
A : int
}
let go () =
let s = { A = 1 }
<@ s.A @>
```
#### Expected behavior
`go` should compile.
#### Actual behavior
`go` gives a compile error (squiggly is under `s` in the quotation) of "A quotation may not involve an assignment to or taking the address of a captured local variable"
Some further examples of quotations that do / don't work:
```fsharp
open FSharp.Quotations
[]
type S =
{
A : int
}
with
member __.B () = 1
member __.C () () = 2
let go () =
let s = { A = 1 }
// # these do not compile if `S` is a struct
// Accessing a field of `S`
let e = <@ s.A @>
// Invoking a member method of `S`
let e = <@ s.B () @>
// # these compile regardless of `S` being a struct
// Accessing a member method of `S`
let e = <@ s.B @>
let e = <@ s.C @>
// Invoking a curried member method of `S`
let e = <@ s.C () @>
let e = <@ s.C () () @>
// Invoking a member method of `S` by accessing it then using a lambda to invoke it
let e = <@ (fun f -> f ()) s.B @>
// Accessing a field of `S` via splicing
let sExpr = <@ s @>
let e = <@ (%sExpr).A @>
// Invoking a member method of `S` via splicing
let e = <@ (%sExpr).B () @>
()
```
#### Known workarounds
No known workarounds.
#### Related information
* Windows
* .NET Framework 4.6.1 and Core 2.0 tested - possibly others
Contributor guide
Assessment
This issue has not been assessed yet.