dotnet / dotnet/fsharp

Investigate why `IsMethod` and `IsProperty` don't act as expected for generated methods/properties

Open
#17,641 0 comments 0 reactions 0 assignees View on GitHub
Area-Compiler-CodeGen Bug Impact-Low
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

Follow up to https://github.com/dotnet/fsharp/issues/17301 - there you can see the discrepancy described in this comment https://github.com/dotnet/fsharp/issues/17301#issuecomment-2292309835

This discrepancy could be a source of more undiscovered bugs similar to 17301

**Repro steps**

Inspect a generated code like `IsUnionCaseTester` property, or `Equals` method by enumerating declarations from assembly contents, like in the snippet from the comment linked above:
```
for impl_file in projectResults.AssemblyContents.ImplementationFiles do
for file_decl in impl_file.Declarations do
match file_decl with
| FSharpImplementationFileDeclaration.Entity (ent, ent_decls) ->
for ent_decl in ent_decls do
match ent_decl with
| FSharpImplementationFileDeclaration.MemberOrFunctionOrValue (mfv, args, body) ->
if mfv.CompiledName.StartsWith("get_Is") then
printfn $"""
--- when enumerating declarations ---
{mfv.CompiledName}:
IsProperty = {mfv.IsProperty}
IsMethod = {mfv.IsMethod}
IsFunction = {mfv.IsFunction}
IsPropertyGetterMethod = {mfv.IsPropertyGetterMethod}
IsValue = {mfv.IsValue}"""
| _ -> ()
| _ -> ()
```

vs

Inspect uses of these generated properties/methods in user code with `GetSymbolUseAtLocation`

**Expected behavior**

`IsUnionCaseTester` property always has `IsProperty` = true and `Equals` always has `IsMethod` = true

**Actual behavior**

When enumerating declarations in generated code, these generated properties/methods are not marked as such.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.