tc39 / proposal-class-public-fields

Stage 2 proposal for public class fields in ECMAScript
https://tc39.github.io/proposal-class-public-fields/
488 stars 25 forks source link

Ban new.target and arguments from initializers #41

Closed littledan closed 8 years ago

michaelficarra commented 8 years ago

Does this cover the cases of arguments or new.target in a direct call to eval in the way we like? Just want to make sure we've considered it.

jeffmo commented 8 years ago

I think arguments is addressed for eval via the arguments implicit binding added here (in that arguments is always undefined). I'm not sure how we should do something similar for new.target?

littledan commented 8 years ago

This returns undefined for arguments or new.target in a direct eval call, unfortunately.

jeffmo commented 8 years ago

Ok, I tweaked this PR to set [[NewTarget]] in the envRec over here: https://github.com/jeffmo/es-class-public-fields/compare/ban_initializer_stuff?expand=1

Will merge in just a second (once everyone's had a chance to skim the new diff)

littledan commented 8 years ago

You don't need to set [[NewTarget]] to undefined; it's already set as that because of the second argument to NewFunctionEnvironment.

jeffmo commented 8 years ago

Ah. Cool -- will fix

jeffmo commented 8 years ago

https://github.com/jeffmo/es-class-public-fields/commit/4fce08730d273f4c6531021ee7efdc0c5b6591cf