This is an unresolved thread from #873. Review in conjunction with #1665.
Dealing with “var x” – Part 2
There is an ambiguity in patterns, the input “var x” could be recognised as a declaration_pattern or as a var_pattern. As is this PR only deals with the latter, on line 191 below, and says nothing about the former.
I think the intended semantics are:
- In declaration_pattern the type cannot be the identifier
var; i.e. if it starts with var then var_pattern is considered.
- A var_pattern is invalid (not considered as a valid parse) if a type called
var is in scope.
This is tackled with two suggestions:
- One on line 83 covering declaration_pattern (Part 1)
- Reword the original statement on line 191
A *var_pattern* cannot be used when a type named `var` is in scope.
Note: I would have moved line 191 to the start of this clause but GitHub will not allow that, that would give:
11.2.4 Var pattern
A var_pattern matches every value. That is, a pattern-matching operation with a var_pattern always succeeds.
A var_pattern is applicable to every type.
A var_pattern cannot be used when a type named var is in scope.
This seems to me to flow better, take your pick.
Originally posted by @Nigel-Ecma in #873 (comment)
This is an unresolved thread from #873. Review in conjunction with #1665.
Dealing with “var x” – Part 2
There is an ambiguity in patterns, the input “var x” could be recognised as a declaration_pattern or as a var_pattern. As is this PR only deals with the latter, on line 191 below, and says nothing about the former.
I think the intended semantics are:
var; i.e. if it starts withvarthen var_pattern is considered.varis in scope.This is tackled with two suggestions:
Originally posted by @Nigel-Ecma in #873 (comment)