wurstscript / WurstScript

Programming language and toolkit to create Warcraft III Maps
https://wurstlang.org
Apache License 2.0
224 stars 30 forks source link

static class use same name function #912

Closed supemeko closed 4 years ago

supemeko commented 4 years ago

like this code

package ReportBug2

class A
    B b = new B()
    function get() returns int
        return b.get()
    static class B
        function get() returns int
            return 1

@Test
function test()
    new A().get()

unit tests result:

Running <ReportBug2:12 - test>..
    FAILED with exception: You encountered a bug in the interpreter: java.lang.RuntimeException: Null pointer dereference
... when calling A_get(0) in ReportBug2.wurst:6
... when calling A_get(5) in ReportBug2.wurst:6
... when calling A_get(4) in ReportBug2.wurst:13
... when calling test() in ReportBug2.wurst:12

Here are some compiler internals, that might help Wurst developers to debug this issue:
    You encountered a bug in the interpreter: java.lang.RuntimeException: Null pointer dereference
    at [C:\Supemeko\Working\WurstTest\wurst\ReportBug2.wurst, line 6]:
You encountered a bug in the interpreter: java.lang.RuntimeException: Null pointer dereference
Stack trace:
at : ReportBug2.wurst, line 6
... when calling A_get(0) in ReportBug2.wurst:6
... when calling A_get(5) in ReportBug2.wurst:6
... when calling A_get(4) in ReportBug2.wurst:13
... when calling test() in ReportBug2.wurst:12

    at de.peeeq.wurstscript.intermediatelang.interpreter.ILInterpreter.runFunc(ILInterpreter.java:116)
    at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.evaluateFunc(EvaluateExpr.java:45)
    at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.eval(EvaluateExpr.java:36)
    at de.peeeq.wurstscript.jassIm.ImFunctionCallImpl.evaluate(ImFunctionCallImpl.java:239)
    at de.peeeq.wurstscript.intermediatelang.interpreter.RunStatement.run(RunStatement.java:54)
    at de.peeeq.wurstscript.jassIm.ImReturnImpl.runStatement(ImReturnImpl.java:155)
    at de.peeeq.wurstscript.intermediatelang.interpreter.RunStatement.run(RunStatement.java:69)
    at de.peeeq.wurstscript.jassIm.ImStmtsImpl.runStatements(ImStmtsImpl.java:84)
    at de.peeeq.wurstscript.intermediatelang.interpreter.ILInterpreter.runFunc(ILInterpreter.java:94)
    at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.evaluateFunc(EvaluateExpr.java:45)
    at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.eval(EvaluateExpr.java:36)
    at de.peeeq.wurstscript.jassIm.ImFunctionCallImpl.evaluate(ImFunctionCallImpl.java:239)
    at de.peeeq.wurstscript.intermediatelang.interpreter.RunStatement.run(RunStatement.java:54)
    at de.peeeq.wurstscript.jassIm.ImReturnImpl.runStatement(ImReturnImpl.java:155)
    at de.peeeq.wurstscript.intermediatelang.interpreter.RunStatement.run(RunStatement.java:69)
    at de.peeeq.wurstscript.jassIm.ImStmtsImpl.runStatements(ImStmtsImpl.java:84)
    at de.peeeq.wurstscript.intermediatelang.interpreter.ILInterpreter.runFunc(ILInterpreter.java:94)
    at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.evaluateFunc(EvaluateExpr.java:45)
    at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.eval(EvaluateExpr.java:196)
    at de.peeeq.wurstscript.jassIm.ImMethodCallImpl.evaluate(ImMethodCallImpl.java:252)
    at de.peeeq.wurstscript.intermediatelang.interpreter.RunStatement.run(RunStatement.java:16)
    at de.peeeq.wurstscript.jassIm.ImMethodCallImpl.runStatement(ImMethodCallImpl.java:248)
    at de.peeeq.wurstscript.intermediatelang.interpreter.RunStatement.run(RunStatement.java:69)
    at de.peeeq.wurstscript.jassIm.ImStmtsImpl.runStatements(ImStmtsImpl.java:84)
    at de.peeeq.wurstscript.intermediatelang.interpreter.ILInterpreter.runFunc(ILInterpreter.java:94)
    at de.peeeq.wurstscript.intermediatelang.interpreter.ILInterpreter.runVoidFunc(ILInterpreter.java:201)
    at de.peeeq.wurstio.languageserver.requests.RunTests.lambda$runTests$0(RunTests.java:180)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Null pointer dereference
    at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.eval(EvaluateExpr.java:202)
    at de.peeeq.wurstscript.jassIm.ImMemberAccessImpl.evaluate(ImMemberAccessImpl.java:262)
    at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.evaluateFunc(EvaluateExpr.java:43)
    at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.eval(EvaluateExpr.java:36)
    at de.peeeq.wurstscript.jassIm.ImFunctionCallImpl.evaluate(ImFunctionCallImpl.java:239)
    at de.peeeq.wurstscript.intermediatelang.interpreter.RunStatement.run(RunStatement.java:54)
    at de.peeeq.wurstscript.jassIm.ImReturnImpl.runStatement(ImReturnImpl.java:155)
    at de.peeeq.wurstscript.intermediatelang.interpreter.RunStatement.run(RunStatement.java:69)
    at de.peeeq.wurstscript.jassIm.ImStmtsImpl.runStatements(ImStmtsImpl.java:84)
    at de.peeeq.wurstscript.intermediatelang.interpreter.ILInterpreter.runFunc(ILInterpreter.java:94)
    ... 34 more

Tests succeeded: 0/1
>> 1 Tests have failed!

My version is not up to date I don't know if this BUG has been fixed yet

peq commented 4 years ago

Thanks for providing a minimized example with the bug report :)