Actions
Bug #15437
closed正規表現の名前付きキャプチャでASCII以外の大文字で定義したクラスが上書きされる
Description
ASCIIの大文字で定義したクラスは正規表現の名前付きキャプチャで上書きされませんが、ASCII以外の大文字で定義したクラスは上書きされてしまうようです。
これは意図的ですか?
# rewrite_constant_by_named_capture.rb
class C
end
/(?<C>C)/ =~ "C"
p C
class 𝐂
end
/(?<𝐂>𝐂)/ =~ "𝐂"
p 𝐂
C.new
𝐂.new
% ruby -v rewrite_constant_by_named_capture.rb
ruby 2.6.0rc2 (2018-12-15 trunk 66408) [x86_64-linux]
C
rewrite_constant_by_named_capture.rb:11: warning: already initialized constant 𝐂
rewrite_constant_by_named_capture.rb:8: warning: previous definition of 𝐂 was here
"𝐂"
Traceback (most recent call last):
rewrite_constant_by_named_capture.rb:16:in `<main>': undefined method `new' for "𝐂":String (NoMethodError)
Did you mean? next
Updated by naruse (Yui NARUSE) almost 6 years ago
- Target version set to 2.6
- Backport changed from 2.4: UNKNOWN, 2.5: UNKNOWN to 2.4: DONTNEED, 2.5: DONTNEED
Updated by nobu (Nobuyoshi Nakada) almost 6 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r66463.
parse.y: ignore constant name captures
- parse.y (reg_named_capture_assign_iter): ignore non-local name
captures, including non-ASCII constant names.
[ruby-dev:50719] [Bug #15437]
Updated by nobu (Nobuyoshi Nakada) almost 6 years ago
- Description updated (diff)
Actions
Like0
Like0Like0Like0