Project

General

Profile

Actions

Bug #22004

closed

parse.y doesn't executes loop body with `while true || true` condition

Bug #22004: parse.y doesn't executes loop body with `while true || true` condition

Added by Earlopain (Earlopain _) 29 days ago. Updated 3 days ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 4.1.0dev (2026-04-15T13:47:25Z master d077df24a2) +PRISM [x86_64-linux]
[ruby-core:125279]

Description

while true || true
  puts 1
end

This should never exit but with parse.y, the body is never executed. It seems to happen when one of the conditions is a truthy literal. Something similar happens with unitl:

until false && true
  puts 1
end

By moving the literals out to methods that just return them, it behaves like I would expect. Seems to have started happening in Ruby 3.3.

Updated by nobu (Nobuyoshi Nakada) 11 days ago Actions #1

  • Status changed from Open to Closed

Applied in changeset git|7f4f3c8ee7cde795dc27be753796fc7ea8318565.


[Bug #22004] Fix short-circuited loop conditions

Updated by nagachika (Tomoyuki Chikanaga) 10 days ago Actions #2 [ruby-core:125402]

  • Backport changed from 3.3: WONTFIX, 3.4: REQUIRED, 4.0: REQUIRED to 3.3: WONTFIX, 3.4: DONE, 4.0: REQUIRED

Backported into ruby_3_4 at fdac94eee1a3f226cafcfa6ec0da97bb08b03369

Updated by k0kubun (Takashi Kokubun) 3 days ago Actions #3 [ruby-core:125463]

  • Backport changed from 3.3: WONTFIX, 3.4: DONE, 4.0: REQUIRED to 3.3: WONTFIX, 3.4: DONE, 4.0: DONE
Actions

Also available in: PDF Atom