Skip to content

Commit

Permalink
Improve error message for NodeUtil.addFeatureToScript preconditions c…
Browse files Browse the repository at this point in the history
…heck

PiperOrigin-RevId: 609392680
  • Loading branch information
lauraharker authored and copybara-github committed Feb 22, 2024
1 parent 3f72162 commit 1701040
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/com/google/javascript/jscomp/NodeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6004,7 +6004,12 @@ static void addFeatureToScript(Node scriptNode, Feature feature, AbstractCompile
if (feature != Feature.MODULES) {
// Except MODULES (which can get reintroduced later in ConvertChunksToEsModules pass),
// prohibit passes from reintroducing any feature that already got transpiled.
checkState(compiler.getAllowableFeatures().contains(feature));
checkState(
compiler.getAllowableFeatures().contains(feature),
"Cannot add feature: %s. It is not supported in the output language, and either 1) its"
+ " corresponding transpilation pass has already run or 2) transpilation of this"
+ " feature is unsupported entirely",
feature);
} else {
compiler.setAllowableFeatures(compiler.getAllowableFeatures().with(feature));
}
Expand Down

0 comments on commit 1701040

Please sign in to comment.