Project

General

Profile

Actions

Bug #1376

closed

inline symbols/fixnums in a case expression do not honor an overwritten #=== method

Added by lrz (Laurent Sansonetti) over 15 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.1 (2008-12-28 patchlevel-5000 trunk 21107) [i386-darwin9.5.0]
Backport:
[ruby-core:23190]

Description

=begin
The case expression in Ruby 1.9 does not seem to honor the fact that Symbol#=== could have been overwritten prior to the expression.

An example with both Ruby 1.8 and Ruby 1.9:

$ ruby -e "class Symbol; def ===(o); p 42; true; end; end; case :foo; when :foo; end"
42

$ ruby19 -e "class Symbol; def ===(o); p 42; true; end; end; case :foo; when :foo; end"
$

The same problem seems to exist with fixnums as well.
=end

Actions #1

Updated by phasis68 (Heesob Park) over 15 years ago

=begin
In case of variable, it works.

class Symbol
def ===(o)
p 42
true
end
end

this works

a = :foo
case :foo
when a
p 'a'
end

this dosen't work

case :foo
when :foo
p 'b'
end

=end

Actions #2

Updated by yugui (Yuki Sonoda) over 15 years ago

  • Assignee set to ko1 (Koichi Sasada)
  • Priority changed from Normal to 3

=begin

=end

Actions #3

Updated by yugui (Yuki Sonoda) over 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r24092.
=end

Actions #4

Updated by nobu (Nobuyoshi Nakada) over 15 years ago

  • Status changed from Closed to Assigned

=begin

=end

Actions #5

Updated by ko1 (Koichi Sasada) over 15 years ago

  • Status changed from Assigned to Closed

=begin
Applied in changeset r24511.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0