bazelbuild / rules_closure

Closure rules for Bazel
https://developers.google.com/closure
Apache License 2.0
153 stars 114 forks source link

JsChecker NullPointerException when there is a function redefinition #266

Open zoukyle opened 6 years ago

zoukyle commented 6 years ago

If a javascript class has a function redefined, the JsChecker will crash with the NullPointerException. This is critical because in react, we had to use this.toggleButton = this.toggleButton.bind(this); And this is considered as function redefinition.

ERROR: /home/liangzou/gitreview/XXX/javascript/common/react/components/BUILD:18:1: Checking 3 JS files in //javascript/common/react/components:search failed (Exit 1). ERROR: Program threw uncaught exception with args: JsChecker --label //javascript/common/react/components:search --output bazel-out/local-fastbuild/bin/javascript/common/react/components/search.pbtxt --output_errors bazel-out/local-fastbuild/bin/javascript/common/react/components/search-stderr.txt --output_ijs_file bazel-out/local-fastbuild/bin/javascript/common/react/components/search.i.js --convention CLOSURE --src javascript/common/react/components/search.js --src javascript/common/react/components/search_form.js --src javascript/common/react/components/search_details.js --dep bazel-out/local-fastbuild/bin/external/io_bazel_rules_closure/closure/library/library.pbtxt --dep bazel-out/local-fastbuild/bin/javascript/third_party/react/react_with_addons_lib.pbtxt --dep bazel-out/local-fastbuild/bin/javascript/common/services/query_class_lib.pbtxt --dep bazel-out/local-fastbuild/bin/javascript/third_party/react/react_material_ui_lib.pbtxt java.lang.NullPointerException at com.google.javascript.jscomp.ijs.ConvertToTypedInterface$SimplifyDeclarations.shouldRemove(ConvertToTypedInterface.java:521) at com.google.javascript.jscomp.ijs.ConvertToTypedInterface$SimplifyDeclarations.processDeclaration(ConvertToTypedInterface.java:443) at com.google.javascript.jscomp.ijs.ConvertToTypedInterface$SimplifyDeclarations.simplifyAll(ConvertToTypedInterface.java:437) at com.google.javascript.jscomp.ijs.ConvertToTypedInterface.processFile(ConvertToTypedInterface.java:96) at com.google.javascript.jscomp.ijs.ConvertToTypedInterface.process(ConvertToTypedInterface.java:87) at com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process(PhaseOptimizer.java:300) at com.google.javascript.jscomp.PhaseOptimizer.process(PhaseOptimizer.java:227) at com.google.javascript.jscomp.Compiler.check(Compiler.java:1067) at com.google.javascript.jscomp.Compiler.performChecksAndTranspilation(Compiler.java:866) at com.google.javascript.jscomp.Compiler.access$000(Compiler.java:102) at com.google.javascript.jscomp.Compiler$2.call(Compiler.java:800) at com.google.javascript.jscomp.Compiler$2.call(Compiler.java:797) at com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread(CompilerExecutor.java:128) at com.google.javascript.jscomp.Compiler.runInCompilerThread(Compiler.java:854) at com.google.javascript.jscomp.Compiler.stage1Passes(Compiler.java:796) at com.google.javascript.jscomp.Compiler.compile(Compiler.java:713) 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)

Yannic commented 6 years ago

This crash looks like the one that was fixed in https://github.com/google/closure-compiler/commit/3a69df6a9e488a87a42e4d52d3a5450b46ce2e8c#diff-332fe56dabb123e8c2355cba19bf3b20 Updating the compiler to a more recent version should be sufficient.