Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Confusion in python symbol resolving when accessing fields in static class context #2004

Open
oxisto opened this issue Jan 29, 2025 · 0 comments · May be fixed by #2006
Open

Confusion in python symbol resolving when accessing fields in static class context #2004

oxisto opened this issue Jan 29, 2025 · 0 comments · May be fixed by #2006
Labels

Comments

@oxisto
Copy link
Member

oxisto commented Jan 29, 2025

Consider the following snipped:

a = 1

class MyClass:
   copyA = a # this should refer to global a

   def foo():
      self.a = 2

Because currently the PythonAddDeclarationPass is executed before the symbol resolver, it will "correctly" create a new dynamic field a in my class. Therefore, the symbol resolver will "correctly" resolve the reference a in the static class context to the field a. However, in reality, the static context is executed when the class definition is created and the resolution should go to the global a.

This is not easily fixable, unless we merge the PythonAddDeclarationPass into the symbol resolver and then try to resolve in EOG-like order (static class context, then methods) and create dynamic fields on the fly.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
2 participants