fix delete syntax checking under "use strict"
This commit is contained in:
parent
379365d391
commit
a60171c00b
|
|
@ -1470,7 +1470,7 @@ function parse($TEXT, options) {
|
|||
croak("Invalid use of " + op + " operator", token.line, token.col, token.pos);
|
||||
break;
|
||||
case "delete":
|
||||
if (!(expr instanceof AST_PropAccess) && S.input.has_directive("use strict"))
|
||||
if (expr instanceof AST_SymbolRef && S.input.has_directive("use strict"))
|
||||
croak("Calling delete on expression not allowed in strict mode", expr.start.line, expr.start.col, expr.start.pos);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
function f(x) {
|
||||
delete 42;
|
||||
delete (0, x);
|
||||
delete null;
|
||||
delete x;
|
||||
}
|
||||
|
||||
function g(x) {
|
||||
"use strict";
|
||||
delete 42;
|
||||
delete (0, x);
|
||||
delete null;
|
||||
delete x;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -401,7 +401,7 @@ describe("bin/uglifyjs", function () {
|
|||
assert.ok(err);
|
||||
assert.strictEqual(stdout, "");
|
||||
assert.strictEqual(stderr.split(/\n/).slice(0, 4).join("\n"), [
|
||||
"Parse error at test/input/invalid/delete.js:7,11",
|
||||
"Parse error at test/input/invalid/delete.js:13,11",
|
||||
" delete x;",
|
||||
" ^",
|
||||
"ERROR: Calling delete on expression not allowed in strict mode"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user