Bug 885219 - Assertion failure: !exprBody, at jsfun.cpp. r=till.

This commit is contained in:
Jason Orendorff 2013-07-10 08:14:03 -05:00
Родитель 2d582f4b6e
Коммит 2618d89e0e
2 изменённых файлов: 14 добавлений и 5 удалений

Просмотреть файл

@ -0,0 +1,2 @@
if (typeof disassemble === "function")
disassemble("-r", Function("()=>e,d"));

Просмотреть файл

@ -628,12 +628,19 @@ js::FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lamb
StableCharPtr chars = src->chars();
bool exprBody = fun->isExprClosure();
// The source data for functions created by calling the Function
// constructor is only the function's body.
bool funCon = script->sourceStart == 0 && script->scriptSource()->argumentsNotIncluded();
// Functions created with the constructor should not be using the
// expression body extension.
// The source data for functions created by calling the Function
// constructor is only the function's body. This depends on the fact,
// asserted below, that in Function("function f() {}"), the inner
// function's sourceStart points to the '(', not the 'f'.
bool funCon = !fun->isArrow() &&
script->sourceStart == 0 &&
script->sourceEnd == script->scriptSource()->length() &&
script->scriptSource()->argumentsNotIncluded();
// Functions created with the constructor can't be arrow functions or
// expression closures.
JS_ASSERT_IF(funCon, !fun->isArrow());
JS_ASSERT_IF(funCon, !exprBody);
JS_ASSERT_IF(!funCon && !fun->isArrow(), src->length() > 0 && chars[0] == '(');