Question about delete expression + opt chain#313
Question about delete expression + opt chain#313
Conversation
I'm not sure what is the accurate intention here. The text says prohibits listed derivations (in Strict Mode) of UnaryExpression such as `MemberExpression . PrivateIdentifier`. The problem is, OptionalChain is not an immediate derivation, but part of a composition. So I believe the intention is to add he derivations I'm suggesting here. It's a bit verbose but accurate. The original text would target cases like: ```js delete ?. # delete ?.x.#y ``` but they are already not possible. In the suggested prose we disallow: ```js delete this?.#x // OptionalExpression : MemberExpression `?.` PrivateIdentifier delete this?.x.#y // OptionalExpression : MemberExpression OptionalChain PrivateIdentifier delete this?.x?.#x // OptionalExpression : OptionalExpression `?.` PrivateIdentifier delete this?.x?.y.#x // OptionalExpression : OptionalExpression OptionalChain PrivateIdentifier delete super()?.#x // OptionalExpression : CallExpression `?.` PrivateIdentifier delete super()?.x.#y // OptionalExpression : CallExpression OptionalChain PrivateIdentifier delete super().x?.#x delete super()?.x?.y.#x ``` am I missing anything?
|
This feels like a bug in the current private fields spec. But one thing that's confusing me is the part |
|
IMO, the derivation means an expanded form of the given production, rather than contains. This means something like |
|
I understand the "the derived That is, it has to be the whole production, not just a part of it. And yes, @leobalter is correct that the prose currently written talks about Unless someone has a better idea, I expect the fix is going to involve a new |
Here is my original thought, expanding the productions to the listed derived parts as the final nested parts: This has some limitations but I'm not sure how this proposal wants to tackle this: // Invalid: MemberExpression OptionalChain `.` PrivateIdentifier
delete x?.y.#z
// Would be valid: MemberExpression OptionalChain `.` IdentifierName
delete x?.#y.zand etc. |
Yeah, I see how you got there, I am just not convinced it makes sense to talk about a production where you've partially expanded one of the nonterminals. |
|
I've lost my previous answer as Chrome just auto scrolled the whole GitHub page to the left until it was completely gone and there was nothing I could do to recover it. I see your point. In this case I'd like to clarify if this proposal also wants to prevent |
I would not expect it to, that would be surprising. Edit: also the thing you wrote would also prevent |
|
Thanks for the clarification. In this case, we don't have precedent for this, but we could try "ends with" rather than "contains": |
|
Hm, I think I'd prefer introducing a new abstract operation over that. |
|
In this cause I need more time to think how to handle this or also open to anyone's suggestion. Edit: probably following |
|
Edit: sorry, got it totally wrong, retracting. If I understand correctly, the language you want to forbid as Plus I think two of the restrictions in the current spec ( Side question: why is this restriction strict-mode-only? I understand why for regular identifiers, but for private? |
Private fields are a syntax error outside of classes (which are always strict), so it doesn't matter how it would behave in sloppy mode. |
I'm not sure what is the accurate intention here.
The text says prohibits listed derivations (in Strict Mode) of UnaryExpression such as
MemberExpression . PrivateIdentifier.The problem is, OptionalChain is not an immediate derivation, but part of a composition.
So I believe the intention is to add he derivations I'm suggesting here. It's a bit verbose but accurate.
The original text would target cases like:
but they are already not possible.
In the suggested prose we disallow:
am I missing anything?