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

Disable "shadowing" of methods? #24

Open
HLWeil opened this issue Aug 21, 2024 · 3 comments
Open

Disable "shadowing" of methods? #24

HLWeil opened this issue Aug 21, 2024 · 3 comments

Comments

@HLWeil
Copy link
Member

HLWeil commented Aug 21, 2024

Given the following class

type Person(name : string) =
    
    inherit DynamicObj()

    let mutable name = name

    member this.Name
        with get() = name
        and set(value) = name <- value

    member this.Walk () = printfn "%s is walking" name

You can currently set a dynamic property with the same name as an existing method.

let p = Person("John")

p.SetValue("Walk", "Shadowing")

p.Walk() // John is walking

p.GetValue("Walk") // val it: obj = "Shadowing"

Should this work, or fail? @kMutagene

@HLWeil HLWeil changed the title [Feature Request] Disable "shadowing" of methods Disable "shadowing" of methods? Aug 21, 2024
@kMutagene
Copy link
Member

Can we even transpile a lookup of the methods or is than non-transpilable reflection?

@HLWeil
Copy link
Member Author

HLWeil commented Dec 20, 2024

Yes this is transpilable as far as I know. In principle it could the same logic as the Systen.ICloneable.Clone() lookup you implemented for the DeepCopy method. E.g.

[<Emit("""$0["System.ICloneable.Clone"] != undefined && (typeof $0["System.ICloneable.Clone"]) === 'function'""")>]

@kMutagene
Copy link
Member

On another Note, this currently removes the method in transpiled Code right? I think this is expected behaviour in js/py right? So when we prevent this it gets less idiomatic in those languages

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

No branches or pull requests

2 participants