Move safety checks to the end of optimizations
The safety check passes are supposed to happen last to ensure that no
optimizations introduced undeclared variables or other problems.
It appears that some newer passes were accidentally added after them.
@@ -843,10 +843,6 @@ public final class DefaultPassConfig extends PassConfig {
passes.add(rescopeGlobalSymbols);
}
- // Safety checks
- passes.add(checkAstValidity);
- passes.add(varCheckValidity);
-
// Raise to ES2015, if allowed
if (options.getOutputFeatureSet().contains(ES2015)) {
passes.add(optimizeToEs6);
@@ -857,6 +853,10 @@ public final class DefaultPassConfig extends PassConfig {
passes.add(convertChunksToESModules);
}
+ // Safety checks. These should always be the last passes.
+ passes.add(checkAstValidity);
+ passes.add(varCheckValidity);
+
assertValidOrderForOptimizations(passes);
return passes;
}
