Unexpected strict mode reserved word

2,458 views
Skip to first unread message

Steve S

unread,
Jul 3, 2017, 6:57:36 AM7/3/17
to Closure Compiler Discuss
One of my project's target platform is an old browser not permitting the "let" keyword e.g. as a function name, and our build intermittently fails at runtime in this browser with "Unexpected strict mode reserved word".

The latest case was in this line of output:

...function let(e,R,Z,V){...

Here's how we're configuring the build (we use the Java API directly). I'm already trying to explicitly avoid "let", having been unable to find a place in the Closure Compiler source where you already do this:

        RandomNameGenerator rng = new RandomNameGenerator(new Random(buildRevision.hashCode()));
       
        rng
.reset(new HashSet<>(Arrays.asList("break", "case", "catch", "class", "const",

               
"continue", "debugger", "default", "delete", "do", "else", "export", "extends",
               
"finally", "for", "function", "if", "import", "in", "instanceof", "new", "return",
               
"super", "switch", "this", "throw", "try", "typeof", "var", "void", "while", "with",
               
"yield", "enum", "implements", "interface", "let", "package", "private",
               
"protected", "public", "static", "await", "abstract", "boolean", "byte", "char",
               
"double", "final", "float", "goto", "int", "long", "native", "short",
               
"synchronized", "throws", "transient", "volatile")), "", null);
       
        options
.setNameGenerator(rng);

I'm assuming that

NameGenerator.reset()

is being called somewhere, and my preferences are being overwritten/cleared. 

Is there another way to prevent reserved words being used as names? 

Should I file a bug?

Any suggestions to resolve this would be much appreciated.

Mike Samuel

unread,
Jul 5, 2017, 1:01:45 PM7/5/17
to Closure Compiler Discuss
Please file a bug.


In strict mode codelet and static are treated as reserved keywords through static
> semantic restrictions (see 12.1.113.3.1.113.7.5.1, and 14.5.1) rather than the lexical grammar. 

so "let" should be excluded for strict mode compatibility.

Mike Samuel

unread,
Jul 6, 2017, 8:48:14 AM7/6/17
to Closure Compiler Discuss


On Wednesday, July 5, 2017 at 1:01:45 PM UTC-4, Mike Samuel wrote:

Sorry, copy-paste error.  That link should have been to
section 11.6.2.1 Keywords of the ES 6 spec:



Steve S

unread,
Jul 6, 2017, 9:25:38 AM7/6/17
to Closure Compiler Discuss
Thanks. Will do.

Steve S

unread,
Jul 6, 2017, 9:29:27 AM7/6/17
to Closure Compiler Discuss
Reply all
Reply to author
Forward
0 new messages