deleting strict references: SyntaxError or "syntax error"?
On 6/11/14, 11:08 AM, Sergio Maffeis wrote:
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. ... 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.
people.mozilla.org/~jorendorff/es6-draft.html#sec-delete-operator-static-semantics-early-errors says that "delete foo" where foo is an identifier is an early error in strict mode, as far as I can tell.
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?
Browsers are implementing ES6, not ES5.1.
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 jscert.org team