1

Closed

JS Minifier fails on valid syntax

description

The bundle js minifier fails with "run-time warning JS1028: Expected identifier or string: super" while attempting to minify the javascript below:

$$._PendingSendPortFinder = {"":
["ports?", "_visited"],
super: "_MessageTraverser", //<--- this line specifically
visitSendPort$1: function(port) {
if (typeof port === 'object' && port !== null && !!port.is$_BufferingSendPort && port.get$_port() == null)
$.add$1(this.ports, port.get$_futurePort());
}

"super" is reserved, but reserved words actually only apply to Identifiers (vs. IdentifierNames) . As described in es5.github.com/#A.1, these are all IdentifierNames which do not exclude ReservedWords.

a.import
a["import"]
a = { import: "test" }.

The use of 'super' as a PropertyName is permitted, just like 'import' in the last example above.
Closed Sep 7, 2012 at 5:21 PM by danroth27

comments

ronlo wrote Aug 21, 2012 at 1:49 AM

Technically you are correct: the JavaScript specs say object literal names are IdentifierNames, not Identifiers, and can therefore support reserved words in that location. However, practically speaking that is not the case in all browsers. For instance, if you tried to run that code in IE8 or less, you would get a script error. That's why the tool throws an error.

Now, you have brought up a good point: it shouldn't be throwing an error per se -- it should be throwing a cross-browser warning that will show up if you bump up your warning level. I'll get that changed. But if you are trying to get your code to run in all browsers, and IE8 or less is in your matrix, you should not be using reserved words as object literal name without quoting them. Just a good rule of thumb.

wbrian wrote Aug 21, 2012 at 3:38 PM

I came across this issue while trying to minify the javascript output of a Dart application. Dart targets new, compliant browsers, so IE8 is not a concern. Thanks for the quick feedback!