This commit is contained in:
Ingvar Stepanyan 2014-12-30 13:42:06 +02:00
parent 5512e26ac0
commit 0084ac14ae
3 changed files with 38 additions and 2 deletions

View File

@ -2223,7 +2223,8 @@
prop.method = true;
prop.value = parseMethod(isGenerator);
} else if (options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
(prop.key.name === "get" || prop.key.name === "set")) {
(prop.key.name === "get" || prop.key.name === "set") &&
(tokType != _comma && tokType != _braceR)) {
if (isGenerator) unexpected();
prop.kind = prop.key.name;
parsePropertyName(prop);

View File

@ -882,7 +882,8 @@
}
prop.value = parseMethod(isGenerator);
} else if (options.ecmaVersion >= 5 && prop.key.type === "Identifier" &&
(prop.key.name === "get" || prop.key.name === "set")) {
(prop.key.name === "get" || prop.key.name === "set") &&
(token.type != tt.comma && token.type != tt.braceR)) {
prop.kind = prop.key.name;
parsePropertyName(prop);
prop.value = parseMethod(false);

View File

@ -14405,3 +14405,37 @@ test("`{${x}}`, `}`", {
}
}]
}, {ecmaVersion: 6});
// https://github.com/marijnh/acorn/issues/186
test('var {get} = obj;', {
type: "Program",
body: [{
type: "VariableDeclaration",
declarations: [{
type: "VariableDeclarator",
id: {
type: "ObjectPattern",
properties: [{
type: "Property",
method: false,
shorthand: true,
computed: false,
key: {
type: "Identifier",
name: "get"
},
kind: "init",
value: {
type: "Identifier",
name: "get"
}
}]
},
init: {
type: "Identifier",
name: "obj"
}
}],
kind: "var"
}]
}, {ecmaVersion: 6});