Skip to content

Dealing with “var x” – Part 2 #1663

Description

@Nigel-Ecma

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:

  1. One on line 83 covering declaration_pattern (Part 1)
  2. 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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions