From: "naruse (Yui NARUSE) via ruby-core" Date: 2023-01-31T08:19:38+00:00 Subject: [ruby-core:112135] [Ruby master Bug#19379] Regex: "end pattern with unmatched parenthesis" with Ruby 3.2 and interpolation Issue #19379 has been updated by naruse (Yui NARUSE). Backport changed from 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: REQUIRED to 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONE ruby_3_2 ca75332f46c39804e06cd37c2608cbdef0aebf05 merged revision(s) eccfc978fd6f65332eb70c9a46fbb4d5110bbe0a. ---------------------------------------- Bug #19379: Regex: "end pattern with unmatched parenthesis" with Ruby 3.2 and interpolation https://bugs.ruby-lang.org/issues/19379#change-101572 * Author: renchap (Renaud Chaput) * Status: Closed * Priority: Normal * ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin22] * Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONE ---------------------------------------- Sample code: ``` r2 = %r{#c-\w+/comment/[\w-]+} %r{https?://[^/]+#{r2}}x ``` This works with Ruby 3.1: ``` irb(main):001:0> r2 = %r{#c-\w+/comment/[\w-]+} irb(main):002:0> %r{https?://[^/]+#{r2}}x => /https?:\/\/[^\/]+(?-mix:#c-\w+\/comment\/[\w-]+)/x ``` But fails with Ruby 3.2.0: ``` irb(main):022:0> r2 = %r{#c-\w+/comment/[\w-]+} irb(main):023:0> %r{https?://[^/]+#{r2}}x (irb):23:in `
': end pattern with unmatched parenthesis: /https?:\/\/[^\/]+(?-mix:#c-\w+\/comment\/[\w-]+)/x (RegexpError) ``` But if I dont use interpolation, it works correctly: ``` irb(main):001:0> %r{https?://[^/]+#c-\w+/comment/[\w-]+}x => /https?:\/\/[^\/]+#c-\w+\/comment\/[\w-]+/x ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/