From: Yusuke ENDOH Date: 2010-05-19T22:14:17+09:00 Subject: [ruby-dev:41355] Re: [Bug #3319] Regexp#unionの説明と動作で食い違いがある。 遠藤です。 2010年5月19日21:43 Masaya Tarui : > ドキュメントでは要素のどれにでもマッチする正規表現を返すとしているのに対し、 > 実装では、 > ・後方参照を含む場合に他の要素の影響を受けて参照対象がずれる可能性がある。 > ・文字コード10を意味していた'\10'が後方参照として扱われる可能性がある。 > ・同じ名前の名前付き捕獲式集合を持つ要素同士のunionではエラーになる。 > といったものです。 当面は「与えられたパターンにキャプチャがあったら不定」ってことで どうでしょうか。 diff --git a/re.c b/re.c index dddd941..e272146 100644 --- a/re.c +++ b/re.c @@ -3195,6 +3195,7 @@ rb_reg_s_union(VALUE self, VALUE args0) * patterns, i.e., will match any of its parts. The patterns * can be Regexp objects, in which case their options will be preserved, or * Strings. If no patterns are given, returns /(?!)/. + * The behavior is unspecified if any given pattern contains capture. * * Regexp.union #=> /(?!)/ * Regexp.union("penzance") #=> /penzance/ -- Yusuke Endoh