Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readonly field can't use at the ReflectedDefinition function. #514

Closed
bleis-tift opened this issue Jun 25, 2015 · 2 comments
Closed

readonly field can't use at the ReflectedDefinition function. #514

bleis-tift opened this issue Jun 25, 2015 · 2 comments

Comments

@bleis-tift
Copy link

Description:

A readonly field that is defined by C# class can't use at the function with ReflectedDefinition attribute.

Repro Steps:

public class Class1
{
    public readonly string Value;
    public Class1(string v) { this.Value = v; }
}
[<ReflectedDefinition>]
let f () = Class1("aaa").Value

Expected:

Compilation is successful.

Actual:

Compile error.

Quotations cannot contain inline assembly code or pattern matching on arrays

Version: Language, compiler, library, platform version

F# 3.1.2, .NET Framework 4.5, Visual Studio 2013

Workaround: List any known workarounds

  • remove readonly
  • use property
  • remove ReflectedDefinition (but this is unacceptable)
@latkin latkin added the Bug label Jun 25, 2015
@latkin
Copy link
Contributor

latkin commented Jun 25, 2015

Root cause is here. This case handles both [ldsfld] and [ldsfld; nop], but only captures [ldfld]. In this scenario the op is [ldfld; nop] so it falls through to the error case.

The extra nop is deliberately added for readonly fields (here for instance, here for static), so it looks like it was just an oversight to miss this case.

@dsyme dsyme added the pri-2 label Jul 15, 2015
@latkin
Copy link
Contributor

latkin commented Aug 4, 2015

Marking up for grabs, fix is described above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants