[Webkit-unassigned] [Bug 144285] New: ES6 classes invalid toString
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Mon Apr 27 15:54:18 PDT 2015
https://bugs.webkit.org/show_bug.cgi?id=144285
Bug ID: 144285
Summary: ES6 classes invalid toString
Classification: Unclassified
Product: WebKit
Version: 528+ (Nightly build)
Hardware: Unspecified
OS: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: JavaScriptCore
Assignee: webkit-unassigned at lists.webkit.org
Reporter: arv at chromium.org
Given
class C {}
print(C.toString());
this should print
"class C {}"
and not
"function C() {}"
This is important because it is a
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-function.prototype.tostring
"If the object was defined using ECMAScript code and the returned string representation is not in the form of a MethodDefinition or GeneratorMethod then the representation must be such that if the string is evaluated, using eval in a lexical context that is equivalent to the lexical context used to create the original object, it will result in a new functionally equivalent object. In that case the returned source code must not mention freely any variables that were not mentioned freely by the original functionâs source code, even if these âextraâ names were originally in scope."
The behavior of a FunctionDeclaration/FunctionExpression is not equivalent to a ClassDeclaration/ClassExpression. For example try this:
class C {}
assertThrows(function() {
eval(C.toString())();
}, TypeError); // Class constructors cannot be invoked without 'new'
This fails in JSC.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150427/668de098/attachment-0001.html>
More information about the webkit-unassigned
mailing list