commit
a727a121ae
4
acorn.js
4
acorn.js
@ -2824,7 +2824,8 @@
|
||||
prop.method = true;
|
||||
prop.value = parseMethod(isGenerator, isAsync);
|
||||
} else if (options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
|
||||
(prop.key.name === "get" || prop.key.name === "set" || (options.playground && prop.key.name === "memo"))) {
|
||||
(prop.key.name === "get" || prop.key.name === "set"|| (options.playground && prop.key.name === "memo")) &&
|
||||
(tokType != _comma && tokType != _braceR)) {
|
||||
if (isGenerator || isAsync) unexpected();
|
||||
prop.kind = prop.key.name;
|
||||
parsePropertyName(prop);
|
||||
@ -3045,6 +3046,7 @@
|
||||
node.typeParameters = parseTypeParameterDeclaration();
|
||||
}
|
||||
node.superClass = eat(_extends) ? parseMaybeAssign(false, true) : null;
|
||||
if (node.superClass) checkLVal(node.superClass);
|
||||
if (node.superClass && tokType === _lt) {
|
||||
node.superTypeParameters = parseTypeParameterInstantiation();
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -6478,72 +6478,6 @@ test("var A = class extends B {}", {
|
||||
locations: true
|
||||
});
|
||||
|
||||
test("class A extends class B extends C {} {}", {
|
||||
type: "Program",
|
||||
body: [{
|
||||
type: "ClassDeclaration",
|
||||
id: {
|
||||
type: "Identifier",
|
||||
name: "A",
|
||||
loc: {
|
||||
start: {line: 1, column: 6},
|
||||
end: {line: 1, column: 7}
|
||||
}
|
||||
},
|
||||
superClass: {
|
||||
type: "ClassExpression",
|
||||
id: {
|
||||
type: "Identifier",
|
||||
name: "B",
|
||||
loc: {
|
||||
start: {line: 1, column: 22},
|
||||
end: {line: 1, column: 23}
|
||||
}
|
||||
},
|
||||
superClass: {
|
||||
type: "Identifier",
|
||||
name: "C",
|
||||
loc: {
|
||||
start: {line: 1, column: 32},
|
||||
end: {line: 1, column: 33}
|
||||
}
|
||||
},
|
||||
body: {
|
||||
type: "ClassBody",
|
||||
body: [],
|
||||
loc: {
|
||||
start: {line: 1, column: 34},
|
||||
end: {line: 1, column: 36}
|
||||
}
|
||||
},
|
||||
loc: {
|
||||
start: {line: 1, column: 16},
|
||||
end: {line: 1, column: 36}
|
||||
}
|
||||
},
|
||||
body: {
|
||||
type: "ClassBody",
|
||||
body: [],
|
||||
loc: {
|
||||
start: {line: 1, column: 37},
|
||||
end: {line: 1, column: 39}
|
||||
}
|
||||
},
|
||||
loc: {
|
||||
start: {line: 1, column: 0},
|
||||
end: {line: 1, column: 39}
|
||||
}
|
||||
}],
|
||||
loc: {
|
||||
start: {line: 1, column: 0},
|
||||
end: {line: 1, column: 39}
|
||||
}
|
||||
}, {
|
||||
ecmaVersion: 6,
|
||||
ranges: true,
|
||||
locations: true
|
||||
});
|
||||
|
||||
test("class A {get() {}}", {
|
||||
type: "Program",
|
||||
body: [{
|
||||
@ -14420,3 +14354,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