lcompilers / lpython

Python compiler
https://lpython.org/
Other
1.37k stars 156 forks source link

Function symtab not generated when inside class node. #2739

Closed tanay-man closed 6 days ago

tanay-man commented 1 week ago

Test code:

class test:
    x: i32 =1
    def fn_1():
        s : str = "abc"
        print(s)
        return  
def fn_1():
        s : str = "abc"
        print(s)
        return  

For the above code the symtab of the member function is not correctly generated in the ASR.

ASR: ```` (TranslationUnit (SymbolTable 1 { __main__: (Module (SymbolTable 2 { fn_1: (Function (SymbolTable 5 { s: (Variable 5 s [] Local () () Default (Character 1 -2 ()) () Source Public Required .false. ) }) fn_1 (FunctionType [] () Source Implementation () .false. .false. .false. .false. .false. [] .false. ) [] [] [(Assignment (Var 5 s) (StringConstant "abc" (Character 1 3 ()) ) () ) (Print [(Var 5 s)] () () ) (Return)] () Public .false. .false. () ), test: (ClassType (SymbolTable 3 { fn_1: (Function (SymbolTable 4 { }) fn_1 (FunctionType [] () Source Implementation () .false. .false. .false. .false. .false. [] .false. ) [] [] [] () Public .false. .false. () ), x: (Variable 3 x [] Local () () Default (Integer 4) () Source Public Required .false. ) }) test Source Public ) }) __main__ [] .false. .false. ), main_program: (Program (SymbolTable 6 { }) main_program [] [] ) }) [] ) ````
tanay-man commented 1 week ago

Latest code on branch class-node of https://github.com/tanay-man/lpython.git @certik , @Thirumalai-Shaktivel any suggestions on how to fix this?