Skip to content

Commit

Permalink
Remove UNKNOWN_TOGGLES error
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 565191909
  • Loading branch information
shicks authored and copybara-github committed Sep 13, 2023
1 parent acc6e94 commit 385cd58
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
10 changes: 0 additions & 10 deletions src/com/google/javascript/jscomp/ReplaceToggles.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ class ReplaceToggles implements CompilerPass {
"CLOSURE_TOGGLE_ORDINALS must be initialized with an object literal mapping strings to"
+ " booleans or unique whole numbers: {0}");

static final DiagnosticType UNKNOWN_TOGGLE =
DiagnosticType.error(
"JSC_UNKNOWN_TOGGLE",
"goog.readToggleInternalDoNotCallDirectly called with an unknown toggle. If a toggle"
+ " list is given, it must be exhaustive.");

// NOTE: These values are chosen as negative integers because actual toggle ordinals must always
// be non-negative (at least zero). Any negative integers would do to distinguish them from real
// toggle ordinals, but -1 and -2 are the simplest.
Expand Down Expand Up @@ -154,10 +148,6 @@ public void visit(NodeTraversal t, Node n, Node parent) {
return;
}

if (ordinalMapping != null && !ordinalMapping.containsKey(arg.getString())) {
compiler.report(JSError.make(n, UNKNOWN_TOGGLE));
}

Integer ordinal = ordinalMapping != null ? ordinalMapping.get(arg.getString()) : null;
if (ordinal == null || ordinal < 0) {
// No ordinals given: hard-code `true` if explicitly set as true, or `false` otherwise.
Expand Down
7 changes: 4 additions & 3 deletions test/com/google/javascript/jscomp/ReplaceTogglesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.google.javascript.jscomp;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -187,11 +186,13 @@ public void testBootstrapOrdinals_booleanAllowsDuplicates() {

@Test
public void testUnknownToggle() {
testError(
test(
lines(
"var CLOSURE_TOGGLE_ORDINALS = {'foo': 0};",
"const bar = goog.readToggleInternalDoNotCallDirectly('bar');"),
ReplaceToggles.UNKNOWN_TOGGLE);
lines(
"var CLOSURE_TOGGLE_ORDINALS = {'foo': 0};", //
"const bar = false;"));
}

@Test
Expand Down

0 comments on commit 385cd58

Please sign in to comment.