bazelbuild / bazelbuild/rules_closure

NullPointerException in JSChecker

Open
#240 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
159
Forks
111
PR merge metrics
No merged PRs in 30d

Description

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`.

```javascript
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
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with the provided JavaScript syntax-error example using rules_closure v20171203. Start in ConvertToTypedInterface.java around isClassMemberFunction, getClassName, and getPrototypeNameOfThisProp, then compare the stack trace with the compiler's syntax-error handling. Done means the input reports its syntax error without a NullPointerException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, javascript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.