You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In test262-parser-tests, fail/4e885526e8dfaa12.js indicates that an ES parser should raise an (early) syntax error for:
f({x = 0})
I agree that it should, but I think the spec fails to require this.
Presumably the intended syntax error hinges on the fact that {x = 0} is parsed as an instance of the production:
PropertyDefinition : CoverInitializedName
and 13.2.5.1 has an Early Error (EE) rule associated with that production that says:
It is a Syntax Error if any source text is matched by this production.
However, that rule is preceded by a paragraph that gives various conditions under which that rule is not applied, and one of those conditions is "when initially parsing a ... CoverCallExpressionAndAsyncArrowHead". And indeed, the whole expression is a CallExpression, and is parsed via the production:
so it seems we're obliged to not apply the EE rule, and so not raise the Syntax Error.
The "initially parsing" sentence goes back to ES6, but the CoverCallEtc part was added by PR #775 in commit 993e8e4, where it's definitely intentional. However, I think only the AsyncArrowHead side of things was being considered. That is, for the production:
there's an EE rule that requires the CoverCallEtc to cover an AsyncArrowHead. So in that case, it's fine to not apply EE rules on the initial parse of the CoverCallEtc, because it will be re-parsed (as an AsyncArrowHead), which will then apply the EE rules that are appropriate for an AsyncArrowHead.
But consider the CallExpression side of things. By symmetry, you might expect the production:
to have a corresponding EE rule that requires CoverCallEtc to cover something, making it okay to not apply EE rules on the initial parse of CoverCallEtc. But there is no such rule.
In the whole spec, the only semantics associated with that production is an Evaluation rule. Its first step is:
1. Let _expr_ be the |CallMemberExpression| that is covered by |CoverCallExpressionAndAsyncArrowHead|.
so clearly there's an assumption that CoverCallEtc covers a CallMemberExpression, but there's no rule to guarantee it.
(I think the best solution is to add the 'missing' EE rule.)
Back when CoverCallEtc was introduced (with Async Functions in PR #692),it probably wasn't necessary to have such a rule, because the productions:
have the same right-hand side, so any source text matched by the former would necessarily also be matched by the latter.
But while that's true as far as the EBNF is concerned, and even most EE rules, it's not true when you have EE rules whose application depends on whether you're inside a CoverCallEtc.
The text was updated successfully, but these errors were encountered:
I see what you mean about the missing "must cover" rule in 13.2. According to 5.1.4, one should be there: "In such cases a more restrictive supplemental grammar is provided that further restricts the acceptable token sequences. Typically, an early error rule will then state that, in certain contexts, "P must cover an N", where P is a Parse Node (an instance of the generalized production) and N is a nonterminal from the supplemental grammar"
This bug might be resolved by PR #3227, which removes the paragraph containing the sentence:
In addition, [these early error rules] are not applied when initially parsing a [...] CoverCallExpressionAndAsyncArrowHead.
After that removal, I think the 'missing' early error rule (where CoverCallExpressionAndAsyncArrowHead must cover a CallMemberExpression) can be added or not, without affecting the correctness of the spec (but I think adding it would make more sense).
In test262-parser-tests, fail/4e885526e8dfaa12.js indicates that an ES parser should raise an (early) syntax error for:
I agree that it should, but I think the spec fails to require this.
Presumably the intended syntax error hinges on the fact that
{x = 0}
is parsed as an instance of the production:and 13.2.5.1 has an Early Error (EE) rule associated with that production that says:
However, that rule is preceded by a paragraph that gives various conditions under which that rule is not applied, and one of those conditions is "when initially parsing a ... CoverCallExpressionAndAsyncArrowHead". And indeed, the whole expression is a CallExpression, and is parsed via the production:
so it seems we're obliged to not apply the EE rule, and so not raise the Syntax Error.
The "initially parsing" sentence goes back to ES6, but the CoverCallEtc part was added by PR #775 in commit 993e8e4, where it's definitely intentional. However, I think only the AsyncArrowHead side of things was being considered. That is, for the production:
there's an EE rule that requires the CoverCallEtc to cover an AsyncArrowHead. So in that case, it's fine to not apply EE rules on the initial parse of the CoverCallEtc, because it will be re-parsed (as an AsyncArrowHead), which will then apply the EE rules that are appropriate for an AsyncArrowHead.
But consider the CallExpression side of things. By symmetry, you might expect the production:
to have a corresponding EE rule that requires CoverCallEtc to cover something, making it okay to not apply EE rules on the initial parse of CoverCallEtc. But there is no such rule.
In the whole spec, the only semantics associated with that production is an Evaluation rule. Its first step is:
so clearly there's an assumption that CoverCallEtc covers a CallMemberExpression, but there's no rule to guarantee it.
(I think the best solution is to add the 'missing' EE rule.)
Back when CoverCallEtc was introduced (with Async Functions in PR #692),it probably wasn't necessary to have such a rule, because the productions:
and:
have the same right-hand side, so any source text matched by the former would necessarily also be matched by the latter.
But while that's true as far as the EBNF is concerned, and even most EE rules, it's not true when you have EE rules whose application depends on whether you're inside a CoverCallEtc.
The text was updated successfully, but these errors were encountered: