Remove property name clash check in ES6 as per Draft Rev 26.
See https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-06/jun-6.md#conclusionresolution-3 for details. Conflicts: test/tests-harmony.js
This commit is contained in:
parent
5d1db2e993
commit
f26b656ea5
5
acorn.js
5
acorn.js
@ -1433,7 +1433,7 @@
|
||||
// strict mode, init properties are also not allowed to be repeated.
|
||||
|
||||
function checkPropClash(prop, propHash) {
|
||||
if (prop.computed) return;
|
||||
if (options.ecmaVersion >= 6) return;
|
||||
var key = prop.key, name;
|
||||
switch (key.type) {
|
||||
case "Identifier": name = key.name; break;
|
||||
@ -2389,7 +2389,7 @@
|
||||
next();
|
||||
node.id = tokType === _name ? parseIdent() : isStatement ? unexpected() : null;
|
||||
node.superClass = eat(_extends) ? parseExpression() : null;
|
||||
var classBody = startNode(), methodHash = {}, staticMethodHash = {};
|
||||
var classBody = startNode();
|
||||
classBody.body = [];
|
||||
expect(_braceL);
|
||||
while (!eat(_braceR)) {
|
||||
@ -2411,7 +2411,6 @@
|
||||
method.kind = "";
|
||||
}
|
||||
method.value = parseMethod(isGenerator);
|
||||
checkPropClash(method, method['static'] ? staticMethodHash : methodHash);
|
||||
classBody.body.push(finishNode(method, "MethodDefinition"));
|
||||
eat(_semi);
|
||||
}
|
||||
|
||||
@ -9386,17 +9386,156 @@ test("class A { set foo(v) {} get foo() {} }", {
|
||||
locations: true
|
||||
});
|
||||
|
||||
testFail("class A { get foo() {} get foo() {} }", "Redefinition of property (1:27)", {ecmaVersion: 6});
|
||||
|
||||
testFail("class A { set foo(v) {} set foo(v) {} }", "Redefinition of property (1:28)", {ecmaVersion: 6});
|
||||
|
||||
testFail("class A { get foo() {} foo() {} }", "Redefinition of property (1:23)", {ecmaVersion: 6});
|
||||
|
||||
testFail("class A { foo() {} get foo() {} }", "Redefinition of property (1:23)", {ecmaVersion: 6});
|
||||
|
||||
testFail("class A { set foo(v) {} foo() {} }", "Redefinition of property (1:24)", {ecmaVersion: 6});
|
||||
|
||||
testFail("class A { foo() {} set foo(v) {} }", "Redefinition of property (1:23)", {ecmaVersion: 6});
|
||||
test("class A { foo() {} get foo() {} }",{
|
||||
type: "Program",
|
||||
start: 0,
|
||||
end: 33,
|
||||
loc: {
|
||||
start: {line: 1, column: 0},
|
||||
end: {line: 1, column: 33}
|
||||
},
|
||||
range: [0, 33],
|
||||
body: [{
|
||||
type: "ClassDeclaration",
|
||||
start: 0,
|
||||
end: 33,
|
||||
loc: {
|
||||
start: {line: 1, column: 0},
|
||||
end: {line: 1, column: 33}
|
||||
},
|
||||
range: [0, 33],
|
||||
id: {
|
||||
type: "Identifier",
|
||||
start: 6,
|
||||
end: 7,
|
||||
loc: {
|
||||
start: {line: 1, column: 6},
|
||||
end: {line: 1, column: 7}
|
||||
},
|
||||
range: [6, 7],
|
||||
name: "A"
|
||||
},
|
||||
superClass: null,
|
||||
body: {
|
||||
type: "ClassBody",
|
||||
start: 8,
|
||||
end: 33,
|
||||
loc: {
|
||||
start: {line: 1, column: 8},
|
||||
end: {line: 1, column: 33}
|
||||
},
|
||||
range: [8, 33],
|
||||
body: [
|
||||
{
|
||||
type: "MethodDefinition",
|
||||
start: 10,
|
||||
end: 18,
|
||||
loc: {
|
||||
start: {line: 1, column: 10},
|
||||
end: {line: 1, column: 18}
|
||||
},
|
||||
range: [10, 18],
|
||||
static: false,
|
||||
computed: false,
|
||||
key: {
|
||||
type: "Identifier",
|
||||
start: 10,
|
||||
end: 13,
|
||||
loc: {
|
||||
start: {line: 1, column: 10},
|
||||
end: {line: 1, column: 13}
|
||||
},
|
||||
range: [10, 13],
|
||||
name: "foo"
|
||||
},
|
||||
kind: "",
|
||||
value: {
|
||||
type: "FunctionExpression",
|
||||
start: 13,
|
||||
end: 18,
|
||||
loc: {
|
||||
start: {line: 1, column: 13},
|
||||
end: {line: 1, column: 18}
|
||||
},
|
||||
range: [13, 18],
|
||||
id: null,
|
||||
params: [],
|
||||
defaults: [],
|
||||
rest: null,
|
||||
generator: false,
|
||||
body: {
|
||||
type: "BlockStatement",
|
||||
start: 16,
|
||||
end: 18,
|
||||
loc: {
|
||||
start: {line: 1, column: 16},
|
||||
end: {line: 1, column: 18}
|
||||
},
|
||||
range: [16, 18],
|
||||
body: []
|
||||
},
|
||||
expression: false
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "MethodDefinition",
|
||||
start: 19,
|
||||
end: 31,
|
||||
loc: {
|
||||
start: {line: 1, column: 19},
|
||||
end: {line: 1, column: 31}
|
||||
},
|
||||
range: [19, 31],
|
||||
static: false,
|
||||
computed: false,
|
||||
key: {
|
||||
type: "Identifier",
|
||||
start: 23,
|
||||
end: 26,
|
||||
loc: {
|
||||
start: {line: 1, column: 23},
|
||||
end: {line: 1, column: 26}
|
||||
},
|
||||
range: [23, 26],
|
||||
name: "foo"
|
||||
},
|
||||
kind: "get",
|
||||
value: {
|
||||
type: "FunctionExpression",
|
||||
start: 26,
|
||||
end: 31,
|
||||
loc: {
|
||||
start: {line: 1, column: 26},
|
||||
end: {line: 1, column: 31}
|
||||
},
|
||||
range: [26, 31],
|
||||
id: null,
|
||||
params: [],
|
||||
defaults: [],
|
||||
rest: null,
|
||||
generator: false,
|
||||
body: {
|
||||
type: "BlockStatement",
|
||||
start: 29,
|
||||
end: 31,
|
||||
loc: {
|
||||
start: {line: 1, column: 29},
|
||||
end: {line: 1, column: 31}
|
||||
},
|
||||
range: [29, 31],
|
||||
body: []
|
||||
},
|
||||
expression: false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}]
|
||||
},{
|
||||
ecmaVersion: 6,
|
||||
ranges: true,
|
||||
locations: true
|
||||
});
|
||||
|
||||
// ES6: Computed Properties
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user