Better validation to prevent class name being allowed as expression value (which then leads to NullPointerException)
jaccomoc opened this issue · 0 comments
jaccomoc commented
The parser currently allows a class name to appear as the value of an expression in places where this makes no sense.
Since this is not expected, we then get a NullPointerException during the compilation phase.
For example:
class X{}
X
return 1
Leads to this:
java.lang.NullPointerException
at io.jactl.LocalTypes.popVal(LocalTypes.java:279)
at io.jactl.MethodCompiler.popVal(MethodCompiler.java:3032)
at io.jactl.MethodCompiler.compile(MethodCompiler.java:469)
at io.jactl.MethodCompiler.visitExprStmt(MethodCompiler.java:363)
at io.jactl.MethodCompiler.visitExprStmt(MethodCompiler.java:168)
at io.jactl.Stmt$ExprStmt.accept(Stmt.java:261)
at io.jactl.MethodCompiler.compile(MethodCompiler.java:312)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
at io.jactl.MethodCompiler.visitBlock(MethodCompiler.java:336)
at io.jactl.MethodCompiler.visitBlock(MethodCompiler.java:168)
at io.jactl.Stmt$Block.accept(Stmt.java:90)
at io.jactl.MethodCompiler.compile(MethodCompiler.java:312)
at io.jactl.MethodCompiler._compile(MethodCompiler.java:269)
at io.jactl.MethodCompiler.compile(MethodCompiler.java:200)
at io.jactl.ClassCompiler.doCompileMethod(ClassCompiler.java:404)
at io.jactl.ScriptCompiler.compileScriptMain(ScriptCompiler.java:109)
at io.jactl.ScriptCompiler.compile(ScriptCompiler.java:70)
at io.jactl.ScriptCompiler.compileWithCompletion(ScriptCompiler.java:46)
at io.jactl.Compiler.compileWithCompletion(Compiler.java:86)
at io.jactl.Compiler.compileScript(Compiler.java:58)
at io.jactl.Compiler.compileScript(Compiler.java:48)