Conversation
❗ Release notes requiredCaution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository:
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request. You can open this PR in browser to add release notes: open in github.dev
Warning No PR link found in some release notes, please consider adding it.
|
0716cbc to
eeb5b48
Compare
| match isStatic, isSet with | ||
| | false, false -> | ||
| // Instance getter: ldfld | ||
| Some(Expr.Op(TOp.ILAsm([ mkNormalLdfld fspec ], [ ty ]), tinst, argExprs, m)) |
There was a problem hiding this comment.
mkNormalLdfld hardcodes Nonvolatile. C# volatile fields would lose acquire/release semantics. Maybe ILFieldSln should also store isVolatile (retrieved from ILFieldDef at solve time in ConstraintSolver), then branch here between Volatile/Nonvolatile like IlxGen.fs:4001 does for record fields.
| match item with | ||
| | Some(ILFieldItem [ ilfinfo ]) when | ||
| ilfinfo.IsStatic = (not memFlags.IsInstance) | ||
| && (isGet || not ilfinfo.IsInitOnly) |
There was a problem hiding this comment.
Lets add a dedicated message in case of readonly fields — currently falls through to generic error 193 "does not support operator 'set_Key'".
| |> withLangVersionPreview | ||
| |> compileAndRun | ||
| |> shouldSucceed | ||
| |> verifyOutput "42 0" |
There was a problem hiding this comment.
Additional test scenario proposal:
public class Base { public string Name = "base"; }
public class Derived : Base { }let inline getName (x: ^T) = (^T : (member Name : string) x)
getName (Derived()) // should return "base"
Implements fsharp/fslang-suggestions#1323, still missing couple of pieces + I don't like how trait info is constructed for members (with
get_andset_) for "property-looking" accessors.