mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* insns.def (opt_regexpmatch2): Check String#=~ hasn't overridden
before calling rb_reg_match(). * test/ruby/test_string.rb: Test for above. * vm.c (vm_init_redefined_flag): Add BOP flag for String#=~ [ruby-core:57385] [Bug #8953] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
26f7f7da27
commit
c4b4e77c72
4 changed files with 26 additions and 2 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Thu Sep 26 16:51:00 2013 Shota Fukumori <her@sorah.jp>
|
||||
|
||||
* insns.def (opt_regexpmatch2): Check String#=~ hasn't overridden
|
||||
before calling rb_reg_match().
|
||||
|
||||
* test/ruby/test_string.rb: Test for above.
|
||||
|
||||
* vm.c (vm_init_redefined_flag): Add BOP flag for String#=~
|
||||
|
||||
[ruby-core:57385] [Bug #8953]
|
||||
|
||||
Thu Sep 26 16:43:42 2013 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* misc/ruby-electric.el: Avoid use of the interactive function
|
||||
|
|
|
@ -2098,7 +2098,8 @@ opt_regexpmatch2
|
|||
(VALUE obj2, VALUE obj1)
|
||||
(VALUE val)
|
||||
{
|
||||
if (RB_TYPE_P(obj2, T_STRING)) {
|
||||
if (RB_TYPE_P(obj2, T_STRING) &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_MATCH, STRING_REDEFINED_OP_FLAG)) {
|
||||
val = rb_reg_match(obj1, obj2);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -2256,6 +2256,18 @@ class TestString < Test::Unit::TestCase
|
|||
assert_equal Encoding::UTF_8, a.encoding
|
||||
assert_equal Encoding::US_ASCII, b.encoding
|
||||
end
|
||||
|
||||
def test_eq_tilde_can_be_overridden
|
||||
assert_in_out_err([], <<-RUBY, ["foo"], [])
|
||||
class String
|
||||
def =~(str)
|
||||
"foo"
|
||||
end
|
||||
end
|
||||
|
||||
puts "" =~ //
|
||||
RUBY
|
||||
end
|
||||
end
|
||||
|
||||
class TestString2 < TestString
|
||||
|
|
2
vm.c
2
vm.c
|
@ -1095,7 +1095,7 @@ vm_init_redefined_flag(void)
|
|||
OP(Size, SIZE), (C(Array), C(String), C(Hash));
|
||||
OP(EmptyP, EMPTY_P), (C(Array), C(String), C(Hash));
|
||||
OP(Succ, SUCC), (C(Fixnum), C(String), C(Time));
|
||||
OP(EqTilde, MATCH), (C(Regexp));
|
||||
OP(EqTilde, MATCH), (C(Regexp), C(String));
|
||||
#undef C
|
||||
#undef OP
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue