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

Static method calls should not be dispatched to instance methods #5251

Closed
wdanilo opened this issue Feb 5, 2023 · 4 comments
Closed

Static method calls should not be dispatched to instance methods #5251

wdanilo opened this issue Feb 5, 2023 · 4 comments
Labels
--bug Type: bug -compiler p-low Low priority
Milestone

Comments

@wdanilo
Copy link
Member

wdanilo commented Feb 5, 2023

This task is automatically imported from the old Task Issue Board and it was originally created by Pavel Marek.
Original issue is here.


Output of:

type MyType
    Value number
    foo self = self.number
    foo = "static method"

main =
    my_type = MyType.Value 42
    IO.println my_type.foo
    IO.println MyType.foo

should be:

42
"static method"

but instead is:

In module tmp:
Compiler encountered errors:
tmp.enso[82:5-82:23]: Method overloads are not supported: MyType.foo is defined multiple times in this module.
Aborting due to 1 errors and 0 warnings.
Execution finished with an error: Compilation aborted due to errors.

More info in https://discord.com/channels/401396655599124480/1055483105718304818

This blocks implementation of equality on types. Meaning that MyType == MyType won't work, because it dispatches to an instance method Any.==.

Probable cause is #3764

See also https://github.com/enso-org/enso/pull/3956/files/4ff2e40131a037a89e5a60dda872721c5f9caa51#r1053010361

@jdunkerley jdunkerley removed the -libs Libraries: New libraries to be implemented label Feb 6, 2023
@jdunkerley
Copy link
Member

Testing this the example now works so closing for now.

@jdunkerley jdunkerley added this to the Beta Release milestone Feb 7, 2023
@radeusgd
Copy link
Member

radeusgd commented Apr 6, 2023

I just tested the latest build and this again yields:

In module statics123:
Compiler encountered errors:
statics123.enso[6:5-6:25]: Method overloads are not supported: MyType.foo is defined multiple times in this module.
Aborting due to 1 errors and 0 warnings.
Execution finished with an error: Compilation aborted due to errors.
        at <java> org.graalvm.sdk/org.graalvm.polyglot.Value.invokeMember(Value.java:971)
        at <java> org.enso.polyglot.Module.getAssociatedType(Module.scala:19)
        at <java> org.enso.runner.Main$.runMain(Main.scala:787)
        at <java> org.enso.runner.Main$.runSingleFile(Main.scala:719)
        at <java> org.enso.runner.Main$.run(Main.scala:601)
        at <java> org.enso.runner.Main$.main(Main.scala:1095)
        at <java> org.enso.runner.Main.main(Main.scala)

@radeusgd
Copy link
Member

radeusgd commented Apr 6, 2023

This may be reopened (or replaced with a new ticket) depending on outcome of #6216

@radeusgd
Copy link
Member

I have ventured here as part of my research for #8805.

I think it may be worth re-opening this ticket with low(ish) priority in order to at least improve the error message:
instead of the generic Method overloads are not supported: MyType.foo is defined multiple times in this module.
maybe we should do Cannot define both a static and member method with the same name: My_Type.foo.?

IMHO this could be more understandable to users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
--bug Type: bug -compiler p-low Low priority
Projects
Archived in project
Development

No branches or pull requests

3 participants