Project

General

Profile

Actions

Bug #20094

closed

Inline while loop behavior changed unexpectedly in 3.3.0

Added by sisyphus_cg (Sisyphus CG) 5 months ago. Updated 8 days ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:115923]

Description

The behavior of the inline while loop has changed in 3.3.0. This unexpectedly broke my code and I couldn't find anything in the changelog about it so reporting it as a bug.

In ruby <= 3.2:

(p 1) while false      # nothing
(p 1; p 2) while false # nothing

In ruby 3.3:

(p 1) while false      # 1
(p 1; p 2) while false # 1 2

Essentially, if the left hand side looks like a statement, now it is treated as a do-while loop. In ruby 3.2 and less this only happened with explicit use of begin and end.

Updated by jeremyevans0 (Jeremy Evans) 4 months ago

  • Status changed from Open to Closed
Actions #3

Updated by jeremyevans0 (Jeremy Evans) 4 months ago

  • Backport changed from 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN to 3.0: UNKNOWN, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED

Updated by naruse (Yui NARUSE) 3 months ago

  • Backport changed from 3.0: UNKNOWN, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED to 3.0: UNKNOWN, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONE

ruby_3_3 119d447d42d4645ac919ee53f3ec294deaa7c59b merged revision(s) bc002971b6ad483dbf69b8a275c44412bb6ab954.

Updated by rbjl (Jan Lelis) 12 days ago ยท Edited

It seems like the bug is still present in Ruby 3.3.1:

(p 1) while false # 1

Updated by Eregon (Benoit Daloze) 8 days ago

Indeed:

$ ruby -ve '(p 1) while false'
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
$ ruby -ve '(p 1) while false'
ruby 3.3.1 (2024-04-23 revision c56cd86388) [x86_64-linux]
1
Actions

Also available in: Atom PDF

Like0
Like1Like0Like0Like0Like0Like0