Skip to content

Fix nested destructuring after a splat in multiple assignment - #482

Open
sinsoku wants to merge 1 commit into
ruby:masterfrom
sinsoku:fix-masgn-nested-after-splat
Open

Fix nested destructuring after a splat in multiple assignment#482
sinsoku wants to merge 1 commit into
ruby:masterfrom
sinsoku:fix-masgn-nested-after-splat

Conversation

@sinsoku

@sinsoku sinsoku commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Motivation / Background

This Pull Request has been created because a nested target after a splat in a multiple assignment crashes TypeProf:

*a, (b, c) = 1, 2, [3, 4]
#=> Vertex#add_edge: undefined method 'on_type_added' for nil (NoMethodError)

A nested target is a MultiTargetNode, whose ret is nil, so the collected nil became the destination of a graph edge and blew up in the next reinstall. An index or attribute writer got the return vertex of its own call instead, so it silently received the wrong type rather than crashing.

ruby/ruby's test/ruby/test_assignment.rb has one, so TypeProf aborts there. The same target before the splat (a, (b, c) = ...) goes through another branch and has always worked.

Detail

The value of the multiple assignment statement itself stays nil, since MAsgnBox#ret reads an @rhs the box never assigns — this Pull Request leaves that alone.

🤖 Generated with Claude Code

MultiWriteNode#install0 collected the targets after the splat by their
own `ret` instead of the vertex behind their DummyRHSNode. A nested
target (MultiTargetNode) has a nil `ret`, which blew up as the
destination of a graph edge in the next reinstall. The same mistake hit
an index or attribute writer silently: it got the return vertex of its
own call, so the assigned value never reached it.

    *a, (b, c) = 1, 2, [3, 4]
    #=> undefined method 'on_type_added' for nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant