From: "charliesome (Charlie Somerville)" Date: 2013-09-07T15:48:09+09:00 Subject: [ruby-core:57052] [ruby-trunk - Bug #8872] Case statements do not honor a refinement of the '===' method Issue #8872 has been updated by charliesome (Charlie Somerville). Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: REQUIRED ---------------------------------------- Bug #8872: Case statements do not honor a refinement of the '===' method https://bugs.ruby-lang.org/issues/8872#change-41662 Author: jconley88 (Jon Conley) Status: Closed Priority: Normal Assignee: Category: Target version: ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin11.4.2] Backport: 1.9.3: DONTNEED, 2.0.0: REQUIRED =begin Below, I've redefined the ((|===|)) method of symbol to always return true. In ((|RefineTest#uses_refinement|)), I call ((|===|)) directly and the refined method is called. In ((|RefineTest#does_not_use_refinement|)), the ((|===|)) method is called indirectly through a case statement. If the refined ((|===|)) method was called, the result should be ((*'The refinement was used'*)), but this code currently returns ((*'The refinement was not used'*)). module RefineSymbol refine Symbol do def ===(other) true end end end using RefineSymbol class RefineTest def uses_refinement :a === :b end def does_not_use_refinement case :a when :b 'The refinement was used' else 'The refinement was not used' end end end rt = RefineTest.new rt.uses_refinement # => true rt.does_not_use_refinement # => expected 'The refinement was used' but got 'The refinement was not used' =end -- http://bugs.ruby-lang.org/