The Wayback Machine - https://web.archive.org/web/20200908093851/https://github.com/scala-js/scala-js/issues/2638/
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

Interop feature for new.target #2638

Open
sjrd opened this issue Oct 25, 2016 · 2 comments
Open

Interop feature for new.target #2638

sjrd opened this issue Oct 25, 2016 · 2 comments
Labels

Comments

@sjrd
Copy link
Member

@sjrd sjrd commented Oct 25, 2016

I realized we haven't filed this anywhere. We need some interop feature for ES 6's new.target.

IMO the only reasonable thing to do is to provide a new primitive js.newTarget which returns exactly what new.target would return. The front-end will have to ensure that js.newTarget is only used lexically where a new.target would be allowed, i.e., in the constructor of a JavaScript class.

@sjrd sjrd added the language label Oct 25, 2016
@sjrd
Copy link
Member Author

@sjrd sjrd commented Oct 25, 2016

Well, in fact it can also appear in function bodies, in which case it binds in that function. But in an => function, it is not rebound. Just like this, it looks up its lexical environment (to the enclosing class or function).

For the case of binding in function bodies, using a lexical js.newTarget is just as bad as if we had invented js.this to access the this parameter of a function. It seems that, for this use case, we actually need a set of js.NewTargetThisFunctionN :s Worse, IR-wise, this is going to be extremely tricky ...

@sjrd sjrd added this to the v1.0.0 milestone Jan 22, 2017
@sjrd sjrd modified the milestones: v1.0.0-M1, v1.0.0 Jun 3, 2017
@sjrd sjrd modified the milestones: v1.0.0-M2, v1.0.0-M3 Oct 11, 2017
@sjrd
Copy link
Member Author

@sjrd sjrd commented Jan 14, 2018

Once #3247 is in, we'll be able to add this feature in a backward compatible way, so I'm going to delay this to post-1.0.0.

@sjrd sjrd modified the milestones: v1.0.0-M3, Post-v1.0.0 Jan 14, 2018
@gzm0 gzm0 removed this from the Post-v1.0.0 milestone Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.