deleting strict references: SyntaxError or "syntax error"?

Sergio Maffeis maffeis at
Wed Jun 11 08:08:50 PDT 2014

According to paragraph 11.4.1 of ECMA262 v.5.1, and in particular to
point 5.a of that paragraph, a catchable "SyntaxError exception" should
be thrown when deleting a strict reference in strict mode. The code
below tests this feature:

var fun = function (){
    "use strict"; // strict mode
    delete x;     // strict reference
    };            // this assignment should execute fine

try {
    fun ();       // this should throw a SyntaxError
catch (e){
    alert("exception caught as expected");

We found that current browsers instead terminate abruptly the script
execution at parse time, with an error message. This behaviour is
typical of "early errors", described in Chapter 16, but it is not
obvious that the one above should be considered an early error.

Ch.16 says that "syntax errors" must be reported early. Now, while the
code "foo( ^&*bar((]" is clearly a "syntax error", it's not obvious that
throwing a SyntaxError exception should also be considered a "syntax
error" in the same sense. (Section 11.1.5 states explicitly a case where
the latter should happen, but 11.4.1 does not.)

so, should every occurrence in the spec of the wording "throw a
SyntaxError exception" be taken to have the implicit subscript "unless
this can be reported as an early error", or are the browsers diverging
from the spec?

the team

More information about the es-discuss mailing list