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

[Bug] Issue with inheriting symbols from the base class if it's imported from a python module #1345

Open
mgtm98 opened this issue Oct 6, 2024 · 2 comments
Assignees
Labels
bug Something isn't working as expected.

Comments

@mgtm98
Copy link
Collaborator

mgtm98 commented Oct 6, 2024

A symbol from the base class is not visible in the sub class, after investigation I found that the issue is only with base classes that come from python imported modules

p = 5
g = 6

class A:
    def start () -> int:
        return 0
import:py hello_py;

class B :hello_py.A: {}

with entry {
    a = A();
    b = B();

    a.start();
    b.start();
}

To Reproduce

export JACLANG_AST_SYMBOL_INFO_DETAILED=1
jac tool it ast t.jac

Issue can be seen in the following line

21:5 - 21:14            |   +-- FuncCall, 
21:5 - 21:12            |   |   +-- AtomTrailer, 
21:5 - 21:6             |   |   |   +-- Name - b - Type: hello2.B,  SymbolTable: B, SymbolPath: hello2.b
21:6 - 21:7             |   |   |   +-- Token - ., 
21:7 - 21:12            |   |   |   +-- Name - start - Type: builtins.int,  SymbolTable: int, SymbolPath: <No Symbol is associated with this node>           <=== Issue is here
21:12 - 21:13           |   |   +-- Token - (, 
21:13 - 21:14           |   |   +-- Token - ), 
@mgtm98 mgtm98 added the bug Something isn't working as expected. label Oct 6, 2024
@mgtm98
Copy link
Collaborator Author

mgtm98 commented Oct 6, 2024

I investigated the issue and found that the issue is with SymbolTable::inherit_baseclasses_sym in the following line

self.inherit.append(found.decl.sym_tab)

found.decl.sym_tab points to the base class in case of jac module but in case of python class it point to the whole module.

@marsninja we need to discuss this

@marsninja
Copy link
Contributor

@mgtm98 Is there anything tricky about this fix, seems easy to track down the discrepancy. It's certainly worth creating a pr to fix. Did you run into an issue while working on it?

@marsninja marsninja assigned marsninja and mgtm98 and unassigned marsninja and mgtm98 Oct 7, 2024
mgtm98 added a commit that referenced this issue Oct 11, 2024
@kugesan1105 kugesan1105 removed their assignment Oct 14, 2024
mgtm98 added a commit that referenced this issue Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected.
Projects
None yet
Development

No branches or pull requests

3 participants