From d26b7522d9f004d67281c578886b4a6395673b02 Mon Sep 17 00:00:00 2001 From: Alex Zaworski Date: Fri, 17 Mar 2017 10:29:13 -0700 Subject: [PATCH] Allow 'name' as object literal shorthand property (#1617) fixes #1613 --- lib/parse.js | 4 ---- test/compress/harmony.js | 11 +++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/parse.js b/lib/parse.js index 4e671da4..6c79ae6c 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -1998,7 +1998,6 @@ function parse($TEXT, options) { // allow trailing comma break; start = S.token; - var type = start.type; var name = as_property_name(); var value; @@ -2009,9 +2008,6 @@ function parse($TEXT, options) { a.push(concise); continue; } - if (!(start.type !== name)) { - unexpected(S.token); - } value = new AST_SymbolRef({ start: prev(), diff --git a/test/compress/harmony.js b/test/compress/harmony.js index 9f13537c..8b8b8d10 100644 --- a/test/compress/harmony.js +++ b/test/compress/harmony.js @@ -320,3 +320,14 @@ expansion: { } } } + +issue_1613: { + mangle = { toplevel: true }; + input: { + const name = 1; + const foo = { + name + }; + } + expect_exact: "const n=1;const c={name:n};" +}