RESOLVED DUPLICATE of bug 155336 144285
toString doesn't work on ES6 classes
https://bugs.webkit.org/show_bug.cgi?id=144285
Summary toString doesn't work on ES6 classes
Erik Arvidsson
Reported 2015-04-27 15:54:18 PDT
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.
Attachments
WIP (23.75 KB, patch)
2015-05-05 21:51 PDT, Ryosuke Niwa
no flags
Radar WebKit Bug Importer
Comment 1 2015-05-03 17:14:57 PDT
Ryosuke Niwa
Comment 2 2015-05-05 21:51:33 PDT
Ryosuke Niwa
Comment 3 2016-03-30 22:50:26 PDT
*** This bug has been marked as a duplicate of bug 155336 ***
Note You need to log in before you can comment on or make changes to this bug.