Skip to content

Dealing with “var x” – Part 1 #1665

Description

@Nigel-Ecma

Review in conjunction with #1663.


Dealing with “var x” – Part 1

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:

  1. This one, covering declaration_pattern
  2. Reword the original statement on line 191 (Part 2)

The *type* of a *declaration_pattern* cannot be the *identifier* `var`.

> *Note:* In such a case the input may be recognisable as a *var_pattern* (§11.2.4).

Originally posted by @Nigel-Ecma in #873 (comment)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions