Restore Function()'s expected string representation.

R=rossberg@chromium.org
BUG=v8:2470
TEST=mjsunit/regress/regress-2470

Review URL: https://codereview.chromium.org/12687002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13880 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 17500545
......@@ -1710,7 +1710,7 @@ function NewFunction(arg1) { // length == 1
p += '\n/' + '**/';
}
var body = (n > 0) ? ToString(%_Arguments(n - 1)) : '';
var source = '(function(\n' + p + '\n) {\n' + body + '\n})';
var source = '(function(' + p + ') {\n' + body + '\n})';
// The call to SetNewFunctionAttributes will ensure the prototype
// property of the resulting function is enumerable (ECMA262, 15.3.5.2).
......
......@@ -40,3 +40,8 @@ assertThrows('Function("a", "/*", "*/", "/**/");', SyntaxError);
assertDoesNotThrow('Function("//", "//")');
assertDoesNotThrow('Function("//", "//", "//")');
assertThrows('Function("a", "//", "//")', SyntaxError);
// Some embedders rely on the string representation of the resulting
// function in cases where no formal parameters are specified.
var asString = Function("return 23").toString();
assertSame("function anonymous() {\nreturn 23\n}", asString);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment