-
Notifications
You must be signed in to change notification settings - Fork 854
Open
Labels
Area-QuotationsQuotations (compiler support or library). See also "queries"Quotations (compiler support or library). See also "queries"BugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone
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
open FSharp.Quotations
[<Struct>]
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:
open FSharp.Quotations
[<Struct>]
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-QuotationsQuotations (compiler support or library). See also "queries"Quotations (compiler support or library). See also "queries"BugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Type
Projects
Status
New