From: nagachika00@... Date: 2014-01-23T12:04:11+00:00 Subject: [ruby-core:60022] [Backport200 - Backport #8872] Case statements do not honor a refinement of the '===' method Issue #8872 has been updated by Tomoyuki Chikanaga. Assignee changed from Yukihiro Matsumoto to Tomoyuki Chikanaga Hi, I've told matz that this change introduced by r42923 was already released at 2.0.0p353 and matz decided to not to revert the changeset. (see https://twitter.com/yukihiro_matz/status/423500823788662784 ) I will backport r43913 to fix SEGV introduced at r42923. Thanks. ---------------------------------------- Backport #8872: Case statements do not honor a refinement of the '===' method https://bugs.ruby-lang.org/issues/8872#change-44542 * Author: Jon Conley * Status: Assigned * Priority: Normal * Assignee: Tomoyuki Chikanaga * Category: * Target version: * ruby -v: - ---------------------------------------- =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/