
Issue #20956 has been reported by nevans (Nicholas Evans). ---------------------------------------- Bug #20956: Nested alternation pattern matching bug in 3.4.0-rc1 https://bugs.ruby-lang.org/issues/20956 * Author: nevans (Nicholas Evans) * Status: Open * ruby -v: 3.4.0-rc1 * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- I think I've found a pattern matching bug in ruby 3.4.0-rc1. ```ruby [123, ["foo"]] in [_, /\Afoo\b/i | [/\Afoo\z/i, *]] ``` I also tested this in ruby 2.7.8, with: ```ruby case [123, ["foo"]]; in [_, /\Afoo\b/i | [/\Afoo\z/i, *]] then true; else false end ``` These return `true` in ruby 2.7.8, 3.0.7, 3.1.6, 3.2.6, and 3.3.6. But they return false in 3.4.0-rc1. I'm not sure if this is the best example, but it is a simplification of how I came across the bug. Here are some other similar cases, which give the same result in 3.4.0-rc1 and 3.3.6: ```irb irb(main):001> ["foo"] in /\Afoo\b/i | [/\Afoo\z/i, *] => true irb(main):002> [123, ["foo"]] in [_, [/\Afoo\z/i, *]] => true irb(main):003> [["foo"]] in [[/\Afoo\z/i, *]] => true ``` But this case exhibits the bug again: ```irb irb(main):004> [["foo"]] in [/\Afoo\b/i | [/\Afoo\z/i, *]] => false ``` -- https://bugs.ruby-lang.org/