Skip to content

Fix crash in break in loop#356

Closed
pvcresin wants to merge 1 commit intoruby:masterfrom
pvcresin:fix-break-in-loop-bug
Closed

Fix crash in break in loop#356
pvcresin wants to merge 1 commit intoruby:masterfrom
pvcresin:fix-break-in-loop-bug

Conversation

@pvcresin
Copy link
Contributor

@pvcresin pvcresin commented Dec 25, 2025

This PR fixes an error that occurs when breaking out of a loop.

Reproduction

The following code crashes when analyzed.

def foo
  count = 0
  loop do
    count += 1
    begin
      break count if count == 3
    rescue
      break count
    end
  end
end

Approach

A bridge Vertex is added between src and dst to prevent duplication.

mame added a commit to mame/typeprof that referenced this pull request Feb 9, 2026
This change avoids multi-edges by creating an intermediate vertex
between an `break` argument and its iterator's result.

Fixes ruby#356
mame added a commit to mame/typeprof that referenced this pull request Feb 9, 2026
This change avoids multi-edges by creating an intermediate vertex
between an `break` argument and its iterator's result.

Fixes ruby#356

Co-Authored-By: pvcresin <toriyama@sansan.com>
@mame mame mentioned this pull request Feb 9, 2026
@mame
Copy link
Member

mame commented Feb 9, 2026

Thank you, and sorry for the delayed response! I plan to actively respond starting today.

I don't think your change is bad, but I have some reservations about implicitly adding vertexes when a duplicate occurs. I'd like to handle this on the BreakNode side for now.

@mame mame closed this in #365 Feb 9, 2026
pvcresin added a commit to pvcresin/typeprof that referenced this pull request Feb 9, 2026
This change avoids multi-edges by creating an intermediate vertex
between an `break` argument and its iterator's result.

Fixes ruby#356

Co-authored-by: pvcresin <toriyama@sansan.com>
@pvcresin pvcresin deleted the fix-break-in-loop-bug branch February 9, 2026 11:31
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