diff --git a/lib/parse.js b/lib/parse.js index afd87441..3493f8e6 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -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; } diff --git a/test/input/invalid/delete.js b/test/input/invalid/delete.js index ab780344..9753d3af 100644 --- a/test/input/invalid/delete.js +++ b/test/input/invalid/delete.js @@ -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; } diff --git a/test/mocha/cli.js b/test/mocha/cli.js index 523fc369..9d8d496f 100644 --- a/test/mocha/cli.js +++ b/test/mocha/cli.js @@ -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"