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

Unable to call staticmethod on class from qualified import #1959

Closed
plajjan opened this issue Oct 23, 2024 · 2 comments
Closed

Unable to call staticmethod on class from qualified import #1959

plajjan opened this issue Oct 23, 2024 · 2 comments
Labels
bug Something isn't working Compiler Related to the Acton compiler

Comments

@plajjan
Copy link
Contributor

plajjan commented Oct 23, 2024

When importing a class with a qualified import, it is not possible to call staticmethods. It is possible to work around by importing the exact class with a from X import Y and then it is possible to call the staticmethod

In module foo:

class Foo(object):
    def __init__(self):
        pass

    @staticmethod
    def new():
        return Foo()

in main module:

import foo

actor main(env):
    f = foo.Foo.new()
    env.exit(0)

and we get:

kll@Kristians-MacBook-Air imported_staticmethod % acton build
Building project in /Users/kll/dt/acton/test/compiler/imported_staticmethod
  Compiling foo.act for release
   Finished compilation in   0.004 s
  Compiling m.act for release

ERROR: Error when compiling m module: Type error

  |
5 |    f = foo.Foo.new()
  |        ^^^^^^^
The type of the indicated expression (inferred to be () -> foo.Foo) must have an attribute new with type _(+, ++) -> _; no such type is known.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

I added this as a testcase in PR #1958, so when we have a fix, please commit and push it to the imported-staticmethod branch and the test should pass and we can merge that PR.

@plajjan plajjan added bug Something isn't working Compiler Related to the Acton compiler labels Oct 23, 2024
@plajjan
Copy link
Contributor Author

plajjan commented Oct 23, 2024

@nordlander I think you have sort of diagnosed this behavior when we were in a call. I don't remember exactly why it was. I couldn't find an existing issue, so opening this...

@nordlander
Copy link
Contributor

Fixed by #1960.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Compiler Related to the Acton compiler
Development

No branches or pull requests

2 participants