Skip to content

Conversation

@pvcresin
Copy link
Contributor

@pvcresin pvcresin commented Feb 9, 2026

This PR fixes an infinite loop that occurs when a multi-parameter block is passed to methods like sort_by.

Reproduction

The following code causes the analysis to hang.

def OK_1
  { a: 1 }.sort_by do |key_value|
    key_value
  end
end

def OK_2
  { a: 1 }.sort_by do |(key, value)|
    key
  end
end

def NG
  { a: 1 }.sort_by do |key, value|
    key
  end
end

Approach

SplatBox creation is moved from the run phase (Block#accept_args) to the install phase (CallBaseNode#install0), and accept_args now just connects an edge to the pre-existing @f_ary_arg vertex. This keeps the graph structure stable across re-runs and prevents the infinite loop caused by typecheck trigger edges.

@pvcresin pvcresin force-pushed the fix_hash_sort_by_error branch from 7f3724a to bd807e8 Compare February 9, 2026 12:26
Copy link
Member

@mame mame left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@mame mame merged commit 4dc9fa4 into ruby:master Feb 10, 2026
7 checks passed
@mame
Copy link
Member

mame commented Feb 10, 2026

Thank you!

@pvcresin pvcresin deleted the fix_hash_sort_by_error branch February 10, 2026 08:32
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.

2 participants