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

closures don't allow same parameter names as declared in there parent scope #17

Open
dhyey-shah opened this issue Mar 9, 2021 · 0 comments
Assignees

Comments

@dhyey-shah
Copy link
Member

Example:

func A(){
    var a;                 # local variable `a`
    func B(a){          # parameter `a` collides with parent declaration `a`
        cmd.println("I am in B");
    }
    return B;
}

Throws following while compiling:

Exception in thread "main" java.lang.NullPointerException
        at compiler.ast.Node.getSourcePosition(Node.java:55)
        at compiler.analyzer.SemanticsChecker.logError(SemanticsChecker.java:481)
        at compiler.analyzer.SemanticsChecker.visitParamList(SemanticsChecker.java:350)
        at compiler.ast.Node$ParameterListNode.accept(Node.java:794)
        at compiler.analyzer.SemanticsChecker.visitFuncDecl(SemanticsChecker.java:191)
        at compiler.ast.Node$FuncDeclNode.accept(Node.java:763)
        at compiler.analyzer.SemanticsChecker.visitBlock(SemanticsChecker.java:208)
        at compiler.ast.Node$BlockNode.accept(Node.java:1033)
        at compiler.analyzer.SemanticsChecker.visitFuncDecl(SemanticsChecker.java:192)
        at compiler.ast.Node$FuncDeclNode.accept(Node.java:763)
        at compiler.analyzer.SemanticsChecker.visitProgram(SemanticsChecker.java:125)
        at compiler.main.CafeCompiler.compile(CafeCompiler.java:124)
        at compiler.main.cli.CompileCommand.execute(CompileCommand.java:53)
        at compiler.main.Main.compile(Main.java:99)
        at compiler.Main.compile(Main.java:45)
        at compiler.Main.main(Main.java:40)
@dhyey-shah dhyey-shah self-assigned this Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant