Project

General

Profile

Actions

Bug #21674

closed

Possible regression in return case in statement

Bug #21674: Possible regression in return case in statement

Added by jandudulski (Jan Dudulski) 4 months ago. Updated 3 days ago.

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

Description

Suddenly my code started failing in Ruby 3.4.6 and 3.4.7. Shortest code example:

args = [:increased]
context = Data.define(:event).new(:decreased)
case args
in [event]
  context.event in ^event
end

In Ruby prior to 3.4.6 it returns false (as expected) but in 3.4.6 and 3.4.7 it returns :decreased. context.event in ^event still returns false.

Updated by jandudulski (Jan Dudulski) 4 months ago Actions #1 [ruby-core:123732]

  • Description updated (diff)

Typo

Updated by kddnewton (Kevin Newton) 4 months ago Actions #2 [ruby-core:123734]

  • Assignee set to prism

Updated by kddnewton (Kevin Newton) 3 days ago Actions #4

  • Status changed from Open to Closed

Applied in changeset git|c7ed328cd569a258aa949f78f721195e2be15e9e.


[ruby/prism] Fix in handling

in is a unique keyword because it can be the start of a clause or
an infix keyword. We need to be explicitly sure that even though in
could close an expression context (the body of another in clause)
that we are not also parsing an inline in. The exception is the
case of a command call, which can never be the LHS of an expression,
and so we must immediately exit.

[Bug #21925]
[Bug #21674]

https://github.com/ruby/prism/commit/20374ced51

Actions

Also available in: PDF Atom