diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb index e7f3d5a527..ba3256b820 100644 --- a/test/ruby/test_symbol.rb +++ b/test/ruby/test_symbol.rb @@ -514,4 +514,16 @@ class TestSymbol < Test::Unit::TestCase assert_not_equal sym.to_sym.hash, `#{ruby} -e 'puts #{sym.inspect}.to_sym.hash'`.to_i end + + def test_eq_can_be_redefined + assert_in_out_err([], <<-RUBY, ["foo"], []) + class Symbol + def ==(obj) + "foo" + end + end + + puts :a == :a + RUBY + end end diff --git a/vm.c b/vm.c index 6ff1d234a3..814f8b6780 100644 --- a/vm.c +++ b/vm.c @@ -1576,7 +1576,7 @@ vm_init_redefined_flag(void) OP(MULT, MULT), (C(Integer), C(Float)); OP(DIV, DIV), (C(Integer), C(Float)); OP(MOD, MOD), (C(Integer), C(Float)); - OP(Eq, EQ), (C(Integer), C(Float), C(String)); + OP(Eq, EQ), (C(Integer), C(Float), C(String), C(Symbol)); OP(Eqq, EQQ), (C(Integer), C(Float), C(Symbol), C(String), C(NilClass), C(TrueClass), C(FalseClass)); OP(LT, LT), (C(Integer), C(Float));