Bug 1220702 - Part 2: Fix the .method property of certain FunctionDeclaration nodes. r=Waldo.

--HG--
extra : commitid : 4oo17Jwpqp9
extra : rebase_source : f68618834e1e233b3e4084780d1f93ce3b9874a0
This commit is contained in:
Jason Orendorff 2015-11-03 14:51:42 -06:00
parent 8f623568f5
commit ee1aaa35e1
2 changed files with 12 additions and 1 deletions

View File

@ -3233,7 +3233,9 @@ ASTSerializer::property(ParseNode* pn, MutableHandleValue dst)
}
bool isShorthand = pn->isKind(PNK_SHORTHAND);
bool isMethod = pn->pn_right->isKind(PNK_FUNCTION) && kind == PROP_INIT;
bool isMethod =
pn->pn_right->isKind(PNK_FUNCTION) &&
pn->pn_right->pn_funbox->function()->kind() == JSFunction::Method;
RootedValue key(cx), val(cx);
return propertyName(pn->pn_left, &key) &&
expression(pn->pn_right, &val) &&

View File

@ -31,6 +31,15 @@ assertExpr("b = { set [meth](a) { } }", aExpr("=", ident("b"),
objExpr([{ key: computedName(ident("meth")), value: funExpr(null, [ident("a")],
blockStmt([])), method: false, kind: "set"}])));
// Bug 1220702 - If it's not written as a method, `.method` should be false.
assertExpr("({[x]: function () {}})",
objExpr([{
key: computedName(ident("x")),
value: funExpr(null, [], blockStmt([])),
method: false,
kind: "init"
}]));
}
runtest(test);