rules_closure
rules_closure copied to clipboard
NullPointerException in JSChecker
This is similar to #227 and is most likely be a bug in closure compiler (@MatrixFrog), but I'm reporting it here since I wasn't able to find any repo case for the compiler.
The crash only happens when there is a syntax error in the code.
Please notice that I use rules_closure with v20171203
and not v20171023
.
class Foo {
foo() {
return bar({
foo: 'foo': // The syntax error is here!
bar: 'bar',
});
}
bar() {
this.baz = 0;
}
}
null
Node(EXPR_RESULT): test.js:11:4
this.baz = 0;
Parent(SCRIPT): test.js:2:0
class Foo {
at com.google.javascript.jscomp.ConvertToTypedInterface.isClassMemberFunction(ConvertToTypedInterface.java:804)
at com.google.javascript.jscomp.ConvertToTypedInterface.getClassName(ConvertToTypedInterface.java:819)
at com.google.javascript.jscomp.ConvertToTypedInterface.getPrototypeNameOfThisProp(ConvertToTypedInterface.java:767)
at com.google.javascript.jscomp.ConvertToTypedInterface.access$1200(ConvertToTypedInterface.java:56)
at com.google.javascript.jscomp.ConvertToTypedInterface$FileInfo.recordDeclaration(ConvertToTypedInterface.java:488)
at com.google.javascript.jscomp.ConvertToTypedInterface$PropagateConstJsdoc.visit(ConvertToTypedInterface.java:313)
at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:769)
at com.google.javascript.jscomp.NodeTraversal.traverseChildren(NodeTraversal.java:840)
at com.google.javascript.jscomp.NodeTraversal.handleScript(NodeTraversal.java:721)
at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:746)
at com.google.javascript.jscomp.NodeTraversal.traverse(NodeTraversal.java:305)
at com.google.javascript.jscomp.NodeTraversal.traverseEs6(NodeTraversal.java:680)
at com.google.javascript.jscomp.ConvertToTypedInterface.processFile(ConvertToTypedInterface.java:99)
at com.google.javascript.jscomp.ConvertToTypedInterface.process(ConvertToTypedInterface.java:91)
at com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process(PhaseOptimizer.java:304)
at com.google.javascript.jscomp.PhaseOptimizer.process(PhaseOptimizer.java:230)
at com.google.javascript.jscomp.Compiler.check(Compiler.java:1066)
at com.google.javascript.jscomp.Compiler.performChecksAndTranspilation(Compiler.java:865)
at com.google.javascript.jscomp.Compiler.access$000(Compiler.java:101)
at com.google.javascript.jscomp.Compiler$2.call(Compiler.java:799)
at com.google.javascript.jscomp.Compiler$2.call(Compiler.java:796)
at com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread(CompilerExecutor.java:128)
at com.google.javascript.jscomp.Compiler.runInCompilerThread(Compiler.java:853)
at com.google.javascript.jscomp.Compiler.stage1Passes(Compiler.java:795)
at com.google.javascript.jscomp.Compiler.compile(Compiler.java:712)
at com.google.javascript.jscomp.JsChecker.run(JsChecker.java:249)
at com.google.javascript.jscomp.JsChecker.access$300(JsChecker.java:63)
at com.google.javascript.jscomp.JsChecker$Program.apply(JsChecker.java:341)
at io.bazel.rules.closure.worker.LegacyAspect.run(LegacyAspect.java:38)
at io.bazel.rules.closure.ClosureWorker.run(ClosureWorker.java:69)
at io.bazel.rules.closure.worker.PersistentWorker.runProgram(PersistentWorker.java:109)
at io.bazel.rules.closure.worker.PersistentWorker.runAsPersistentWorker(PersistentWorker.java:144)
at io.bazel.rules.closure.worker.PersistentWorker.run(PersistentWorker.java:84)
at io.bazel.rules.closure.ClosureWorker.main(ClosureWorker.java:111)
Caused by: java.lang.NullPointerException
... 34 more
Can we remove the setContinueAfterErrors
call at https://github.com/bazelbuild/rules_closure/blob/master/java/com/google/javascript/jscomp/JsChecker.java#L179 ? Generally an error such as a parse error should stop compilation immediately.
Thanks, removing that call helps and I agree that a parse error should stop compilation immediately.
However, it feels a little awkward that the compiler starts to tell you to add JSC_PARSE_ERROR
to the suppress attribute, but I don't think that's a big issue and JSC_PARSE_ERROR
isn't the only error that can't be suppressed anyway (#229).
foo.js:4: ERROR - Parse error. '}' expected
foo: 'foo': // The syntax error is here!
^
ProTip: "JSC_PARSE_ERROR" can be added to the `suppress` attribute of:
//:foo
1 error(s), 0 warning(s)