closure-compiler
closure-compiler copied to clipboard
ADVANCED mode java.lang.IllegalStateException
Version: v20220502 I use closure-compiler in ADVANCED mode and get java.lang.IllegalStateException
0 error(s), 223 warning(s), 60.6% typed java.lang.IllegalStateException at com.google.common.base.Preconditions.checkState(Preconditions.java:486) at com.google.javascript.rhino.Node.getOnlyChild(Node.java:563) at com.google.javascript.jscomp.NodeUtil.getRValueOfLValue(NodeUtil.java:5190) at com.google.javascript.jscomp.PureFunctionIdentifier.populateFunctionDefinitions(PureFunctionIdentifier.java:423) at java.util.Map.forEach(Map.java:661) at com.google.javascript.jscomp.PureFunctionIdentifier.populateDatastructuresForAnalysisTraversal(PureFunctionIdentifier.java:399) at com.google.javascript.jscomp.PureFunctionIdentifier.process(PureFunctionIdentifier.java:157) at com.google.javascript.jscomp.OptimizeCalls.process(OptimizeCalls.java:124) at com.google.javascript.jscomp.PureFunctionIdentifier$Driver.process(PureFunctionIdentifier.java:1364) at com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process(PhaseOptimizer.java:267) at com.google.javascript.jscomp.PhaseOptimizer.process(PhaseOptimizer.java:186) at com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations(Compiler.java:2572) at com.google.javascript.jscomp.Compiler.lambda$stage2Passes$5(Compiler.java:936) at com.google.javascript.jscomp.CompilerExecutor.lambda$runInCompilerThread$0(CompilerExecutor.java:101) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.lang.Thread.run(Thread.java:829) at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:597) at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:194)
Have no idea how to debug this problem and is there any problems in my code (12000 lines of code) I will be grateful for your help
FYI I used https://github.com/wala/jsdelta to find a reduced version of my crash. It was very fast and simplified it from 500k to only a few lines.
Can you provide the exact command you've been using and potentially the reduced input that @ribrdb mentioned?
This code in NodeUtil.getRValueOfLValue doesn't make sense to me.
case OBJECTLIT:
case CLASS_MEMBERS:
return n.getOnlyChild();
Both OBJECTLIT and CLASS_MEMBERS generally expect to have multiple children
I encountered the same error and managed to reduce it to this:
class Data {
dt;
constructor(data) {
this.dt = data;
}
value() {
return this.dt;
}
}
let j = new Data(3);
console.log(j.value());
The culprit seems to be the uninitialized instance field declaration and the fact that it's accessed inside the value() function.
If I remove the field or initialize it to undefined or remove the access in value(), the error goes away.
Ah, this is an issue with public field handling. Thanks for the report.
yes, the problem is the uninitialized instance field declaration