benjamn / benjamn/ast-types

In core, Pattern should probably only be implemented by MemberExpression (and Identifier)

Open
#225 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
194
Avg merge
22h 43m
Merged PRs (30d)
10

Description

Officially the toplevel "left hand side expression" is defined as:
```
LeftHandSideExpression :
NewExpression
CallExpression
```
where the two productions implement various permutations of attribute accesses, function calls and new calls, *however* a valid LHS should also produce a *reference object*, in theory *host objects* could produce references on simple function calls but in practice that's never the case (let alone constructors doing that), furthermore

> ### Annex E: Additions and Changes That Introduce Incompatibilities with Prior Editions

> [6.2.3](http://www.ecma-international.org/ecma-262/6.0/#sec-reference-specification-type): In ECMAScript 2015, Function calls are not allowed to return a Reference value.

and finally Firefox already throws a `ReferenceError: invalid assignment left-hand side` on *parsing* an assignment to a `new` call (webkit will parse it but fail at runtime).

Thus, I think the AST would be both clearer and more sensible if it were restricted to Identifier and MemberExpression (again in Core)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the Core Pattern implementation and the definitions for Identifier and MemberExpression. Review how other expressions are currently accepted, then verify that Core restricts Pattern implementations to Identifier and MemberExpression without changing unrelated AST behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.