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

returns None instead of void for return type #141

Open
Hareem-E-Sahar opened this issue Dec 8, 2023 · 0 comments
Open

returns None instead of void for return type #141

Hareem-E-Sahar opened this issue Dec 8, 2023 · 0 comments

Comments

@Hareem-E-Sahar
Copy link

Hareem-E-Sahar commented Dec 8, 2023

import javalang

code = """class MyNewClass { 
    int y = 5; 
    public void fun(int i) { 
        int number = i; 
        System.out.println(number);
    }
}"""

tree = javalang.parse.parse(code)

for _, node in tree.filter(javalang.tree.MethodDeclaration):
print(f"Method name: {node.name}")
print(f"Return type: {node.return_type}")

This incorrectly determines the return type to be None instead of void.
Is there a workaround?

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