Project

General

Profile

Actions

Backport #8872

closed

Case statements do not honor a refinement of the '===' method

Added by jconley88 (Jon Conley) over 10 years ago. Updated about 10 years ago.


Description

=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


Related issues 2 (0 open2 closed)

Related to Backport200 - Backport #9175: Backport r43913Closednagachika (Tomoyuki Chikanaga)11/29/2013Actions
Has duplicate Ruby master - Bug #9150: Segfault in case statement execution, possibly related to refinementsClosednagachika (Tomoyuki Chikanaga)11/25/2013Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0