Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid ES6->ES5 lowering of static name & length methods #1460

Open
ochafik opened this issue Jan 28, 2016 · 3 comments
Open

Invalid ES6->ES5 lowering of static name & length methods #1460

ochafik opened this issue Jan 28, 2016 · 3 comments

Comments

@ochafik
Copy link
Contributor

ochafik commented Jan 28, 2016

Function.length and Function.name are not writable, which means the following valid ES6 code is not lowered properly:

class Foo {
  static name() {}
  static length() {}
}
console.log(typeof Foo.name); // function
console.log(typeof Foo.length); // function

Is currently lowered to:

var Foo=function(){};
Foo.name=function(){};
Foo.length=function(){};
console.log(typeof Foo.name); // string
console.log(typeof Foo.length); // number

And should be lowered to something like:

var Foo=function(){};
Object.defineProperty(Foo, 'name', {value: function(){}});
Object.defineProperty(Foo, 'length', {value: function(){}});
console.log(typeof Foo.name); // function
console.log(typeof Foo.length); // function

(this bug came up in some DDC-compiled Dart code)

@ChadKillingsworth
Copy link
Collaborator

That would work for ES5, but not ES3.

@ochafik
Copy link
Contributor Author

ochafik commented Jan 28, 2016

(note: for DDC we're only after ES6->ES5 lowering)
Also, same issue with caller, callee, arguments, etc.

@ChadKillingsworth
Copy link
Collaborator

I think ES6 -> ES3 is probably a small minority (except by accident because that's the default).

I wonder if we can do an ES6 -> ES5 transpilation early, then do a very late ES5 -> ES3 transpilation at the end. That would allows us to convert things like Object.defineProperty after all the other checks and optimizations were complete.

ochafik added a commit to dart-archive/dev_compiler that referenced this issue Feb 3, 2016
…or Closure, to avoid ES5->ES6 lowering bug (google/closure-compiler#1460).

This is part of the overall "simple closure" effort (issue #312)

BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1630963003 .
ochafik added a commit to dart-archive/dev_compiler that referenced this issue Feb 3, 2016
…rties) for Closure, to avoid ES5->ES6 lowering bug (google/closure-compiler#1460)."

This reverts commit a637e1b.
ochafik added a commit to dart-archive/dev_compiler that referenced this issue Feb 3, 2016
…or Closure, to avoid ES5->ES6 lowering bug (google/closure-compiler#1460).

This is part of the overall "simple closure" effort (issue #312)
nex3 pushed a commit to dart-lang/sdk that referenced this issue Aug 31, 2016
…or Closure, to avoid ES5->ES6 lowering bug (google/closure-compiler#1460).

This is part of the overall "simple closure" effort (issue #312)

BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1630963003 .
nex3 pushed a commit to dart-lang/sdk that referenced this issue Aug 31, 2016
…rties) for Closure, to avoid ES5->ES6 lowering bug (google/closure-compiler#1460)."

This reverts commit a637e1b048487629d0d44620eb41e703531ce18d.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants