Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

SuperProperty references in field initializers #13

Closed
jeffmo opened this issue Sep 29, 2015 · 8 comments
Closed

SuperProperty references in field initializers #13

jeffmo opened this issue Sep 29, 2015 · 8 comments

Comments

@jeffmo
Copy link
Member

jeffmo commented Sep 29, 2015

Currently we do not have any explicitly notated support for evaluating SuperProperty references in field initializers. Given that this is available, it seems it would only be natural to also provide SuperProperty as well.

@littledan
Copy link
Member

To me it seems like super property access and this should be part of the same package. Maybe new.target would also go along with super and this. And, to state the obvious, the super constructor is disallowed because the initializers are run after the super constructor returns.

@littledan
Copy link
Member

@michaelficarra @zenparsing @domenic @allenwb @erights and others: Any thoughts on this question?

@domenic
Copy link
Member

domenic commented Apr 4, 2016

My initial intuition is that new.target is not like this and super-properties/methods. Like arguments, new.target is more associated with the actual constructor invocation. Whereas this and super-properties/methods is more associated with "stuff that happens in relation to class instances".

That is, IMO the grouping is:

  • Allowed, due to general association with instances: this, super-properties/methods
  • Disallowed, due to association with constructor invocation: arguments, new.target, explicit constructor arguments, super()-construct.

Willing to be persuaded otherwise, certainly.

@ljharb
Copy link
Member

ljharb commented Apr 4, 2016

I agree with @domenic's intuition. imo new.target should only be permitted in a constructor.

@zenparsing
Copy link
Member

I'm uncomfortable with the level of special-casing required here.

@ljharb
Copy link
Member

ljharb commented Apr 4, 2016

I think the grammar for new.target would have to be special-cased to allow it outside of a function. By default, I'd think it would be disallowed in properties.

@zenparsing
Copy link
Member

@ljharb But we are apparently allowing super properties outside of a method, which is novel. Again, this is a special case scope.

@jeffmo
Copy link
Member Author

jeffmo commented Aug 15, 2016

Per our last meeting, "Initializers run with the semantics of individual anonymous methods with no arguments being run on the class. That explains the scope of this and super property access"

There was general agreement at the last meeting on arguments and new.target as well -- but it turns out there is still some concern about this and needs further discussion. That discussion has been happening over in #34

@jeffmo jeffmo closed this as completed Aug 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants