ES2015 class has wrong toString output

Fixed Issue #6156135

Details

Created
Jan 12, 2016
Privacy
This issue is public.
Reports
Reported by 2 people

Sign in to watch or report this issue.

Steps to reproduce

URL:

Repro Steps:

var C = class C {};
console.log(C.toString()); // “constructor() {}”

Expected Results:

The ES6 spec states at http://www.ecma-international.org/ecma-262/6.0/#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.

This is not satisfied by the "constructor() {}" output as:

var C = constructor() {};

is not valid code. Also, the spec states in the same place:

The string representation must have the syntax of a FunctionDeclaration, FunctionExpression, GeneratorDeclaration, GeneratorExpression, ClassDeclaration, ClassExpression, ArrowFunction, MethodDefinition, or GeneratorMethod depending upon the actual characteristics of the object.

This means ES2015 classes, when toStringed, should return a string in a form of either a ClassDeclaration or a ClassExpression.

Actual Results:

Dev Channel specific:

No

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Kamen M.”

      Changed Assigned To to “ChakraTriage”

      Changed Assigned To from “ChakraTriage” to “Suwei C.”

      Changed Assigned To from “Suwei C.” to “IE S.”

      Changed Status to “Fixed”

    You need to sign in to your Microsoft account to add a comment.

    Sign in