Fixed #186.
This commit is contained in:
parent
5512e26ac0
commit
0084ac14ae
3
acorn.js
3
acorn.js
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user