whitequark / whitequark/parser

multi-level mlhs treated as single level

Open
#825 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Yacc
Stars
1.6k
Forks
205
PR merge metrics
No merged PRs in 30d

Description

This bug was found in opal/opal#1703

$ ruby-parse -e '((x, y)) = [[1,2]]'
(masgn
  (mlhs             # <- shouldn't this be (mlhs (mlhs ... ))?
    (lvasgn :x)
    (lvasgn :y))
  (array
    (array
      (int 1)
      (int 2))))
$ ruby-parse -e '(x, y) = [[1,2]]'
(masgn
  (mlhs            # <- the same as above, can't differentiate
    (lvasgn :x)
    (lvasgn :y))
  (array
    (array
      (int 1)
      (int 2))))
$ ruby-parse -V
ruby-parse based on parser version 3.0.2.0
$

This also happens in all legacy modes. This works correctly for ((x,y),) and for ((x,y),z)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the two ruby-parse reproductions shown in the issue and trace the parser entry point that builds the masgn/mlhs AST. The fix is done when ((x, y)) = [[1,2]] produces a nested mlhs distinct from (x, y) = [[1,2]], while the existing ((x,y),) and ((x,y),z) behavior remains correct in legacy modes.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
compilers
Issue type
Bug
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.