[ruby-core:116627] [Ruby master Bug#20246] Unexpected behavior for Regexp in Subexpression Calls on Ruby 3.3.0

Issue #20246 has been reported by bestwebua (Vladislav Trotsenko). ---------------------------------------- Bug #20246: Unexpected behavior for Regexp in Subexpression Calls on Ruby 3.3.0 https://bugs.ruby-lang.org/issues/20246 * Author: bestwebua (Vladislav Trotsenko) * Status: Open * Priority: Normal * ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin22] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Hello! A few days ago, after migration on 3.3.0 I have faced with issue inside subexpression calls. An expected result on Ruby up to 3.3.0: ```ruby '1.2.3'[/(\d+)(\.\g<1>){2}/] # => "1.2.3" ``` An actual result on Ruby 3.3.0: ```ruby '1.2.3'[/(\d+)(\.\g<1>){2}/] # => nil ``` -- https://bugs.ruby-lang.org/

Issue #20246 has been updated by make_now_just (Hiroya Fujinami). This is a bug in regex optimization. Some optimizations have been disabled for memoization since 3.3.0. Therefore, another optimization was enabled, and that bug has surfaced. By complicating the content of the first loop, we can confirm that the same problem occurs in 3.2.0 and earlier. ``` $ ruby --version ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22] $ ruby -e 'p "1.2.3"[/((?:\d|foo|bar)+)(\.\g<1>){2}/]' nil ``` [#9897](https://github.com/ruby/ruby/pull/9897) will fix this bug. ---------------------------------------- Bug #20246: Unexpected behavior for Regexp in Subexpression Calls on Ruby 3.3.0 https://bugs.ruby-lang.org/issues/20246#change-106644 * Author: bestwebua (Vladislav Trotsenko) * Status: Open * Priority: Normal * ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin22] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Hello! A few days ago, after migration on 3.3.0 I have faced with issue inside subexpression calls. An expected result on Ruby up to 3.3.0: ```ruby '1.2.3'[/(\d+)(\.\g<1>){2}/] # => "1.2.3" ``` An actual result on Ruby 3.3.0: ```ruby '1.2.3'[/(\d+)(\.\g<1>){2}/] # => nil ``` -- https://bugs.ruby-lang.org/

Issue #20246 has been updated by naruse (Yui NARUSE). Backport changed from 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: REQUIRED to 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: DONE ruby_3_3 05787897f69087abdabee926971cdf364bd73730 merged revision(s) 18ee7c9a108bf3424814565377c8796e5e455cf7,4a6384ed9358e8fb8464f6e37efb5477182f01db. ---------------------------------------- Bug #20246: Unexpected behavior for Regexp in Subexpression Calls on Ruby 3.3.0 https://bugs.ruby-lang.org/issues/20246#change-107399 * Author: bestwebua (Vladislav Trotsenko) * Status: Closed * ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin22] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: DONE ---------------------------------------- Hello! A few days ago, after migration on 3.3.0 I have faced with issue inside subexpression calls. An expected result on Ruby up to 3.3.0: ```ruby '1.2.3'[/(\d+)(\.\g<1>){2}/] # => "1.2.3" ``` An actual result on Ruby 3.3.0: ```ruby '1.2.3'[/(\d+)(\.\g<1>){2}/] # => nil ``` -- https://bugs.ruby-lang.org/
participants (3)
-
bestwebua (Vladislav Trotsenko)
-
make_now_just (Hiroya Fujinami)
-
naruse (Yui NARUSE)