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

Function symtab not generated when inside class node. #2739

Closed
tanay-man opened this issue Jun 19, 2024 · 1 comment
Closed

Function symtab not generated when inside class node. #2739

tanay-man opened this issue Jun 19, 2024 · 1 comment

Comments

@tanay-man
Copy link
Contributor

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
Copy link
Contributor Author

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

@tanay-man tanay-man closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 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

1 participant