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

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

Open
abonie opened this issue Aug 30, 2024 · 0 comments
Labels
Area-Compiler-CodeGen IlxGen, ilwrite and things at the backend Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone

Comments

@abonie
Copy link
Member

abonie commented Aug 30, 2024

Follow up to #17301 - there you can see the discrepancy described in this comment #17301 (comment)

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.

@github-actions github-actions bot added this to the Backlog milestone Aug 30, 2024
@abonie abonie added Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. Area-Compiler-CodeGen IlxGen, ilwrite and things at the backend and removed Needs-Triage labels Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compiler-CodeGen IlxGen, ilwrite and things at the backend Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Projects
Status: New
Development

No branches or pull requests

1 participant