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

Incorrect behavior observed when calling a method due to local variable name conflicting with an imported module name. #194

Closed
learnforpractice opened this issue Feb 10, 2023 · 1 comment

Comments

@learnforpractice
Copy link
Contributor

I am encountering an issue where the code is not behaving as expected when calling a method in a class.

Here is the relevant code:

a.codon

class A(object):
    pass

test.codon

from a import A

class B(object):
    def say_hello(self):
        print('hello, world from A')

def test():
    a = B()
    a.say_hello()

test()

The code is using a class B that has a method named say_hello, but the method is being recognized as a function from a module a instead of the method in class B. The error message test.codon:9:2-15: error: say_hello() missing 1 required positional argument: 's' is indicating that the method say_hello is being recognized as the function say_hello from module a that requires a positional argument s.

Steps to reproduce:

  1. Run codon run test.codon.

Expected behavior:

The expected output is:

hello, world from A

Actual behavior:

The actual output is:

test.codon:9:2-15: error: say_hello() missing 1 required positional argument: 's'
╰─ test.codon:11:1-5: error: during the realization of test()
@inumanag
Copy link
Contributor

inumanag commented Nov 5, 2024

Fixed in #604

@inumanag inumanag closed this as completed Nov 5, 2024
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