Bug #20246
closedUnexpected behavior for Regexp in Subexpression Calls on Ruby 3.3.0
Description
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:
'1.2.3'[/(\d+)(\.\g<1>){2}/] # => "1.2.3"
An actual result on Ruby 3.3.0:
'1.2.3'[/(\d+)(\.\g<1>){2}/] # => nil
Updated by make_now_just (Hiroya Fujinami) 6 months ago
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 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 will fix this bug.
Updated by naruse (Yui NARUSE) 6 months ago
- Backport changed from 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN to 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: REQUIRED
Updated by make_now_just (Hiroya Fujinami) 6 months ago
- Status changed from Open to Closed
Applied in changeset git|4a6384ed9358e8fb8464f6e37efb5477182f01db.
Fix [Bug #20246]: Don't set next_head_exact if a capture is called (#9897)
Updated by naruse (Yui NARUSE) 5 months ago
- 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.
Updated by k0kubun (Takashi Kokubun) 3 months ago
- Has duplicate Bug #20285: Stale inline method caches when refinement modules are reopened added