Bug #20094
closed
Inline while loop behavior changed unexpectedly in 3.3.0
Added by sisyphus_cg (Sisyphus CG) 11 months ago.
Updated 6 months ago.
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
.
- Status changed from Open to Closed
- 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
- 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.
It seems like the bug is still present in Ruby 3.3.1:
(p 1) while false # 1
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
Can we reopen this bug (please), or should we create a new issue?
- ruby -v changed from 3.3.0 to 3.3.1
- Backport changed from 3.0: UNKNOWN, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONE to 3.0: UNKNOWN, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED
I see the issue was fixed on master branch.
I will revert back Backport field to "3.3: REQUIRED", but stay the ticket status "Closed.
- 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
It was previously reverted presumably because the cherry-pick of bc002971b6ad483dbf69b8a275c44412bb6ab954 to ruby_3_3
doesn't really work. I had to manually create a whole backport patch without relying on git for that reason. I encourage people to file a backport pull request to ruby_3_3
(and make the CI green, which was the hard thing for this ticket) if you want to see a change backported to stable branches.
It seems like the bug is still present in Ruby 3.3.1
Ruby 3.3.2 has been released today. It shouldn't have this issue.
Also available in: Atom
PDF
Like0
Like1Like0Like0Like0Like0Like0Like0Like0Like0Like0Like1Like1