Project

General

Profile

Actions

Bug #15640

closed

Inconsistent value passed to respond_to_missing?

Added by kirun (Kieran Leigh) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
[ruby-core:91683]

Description

If the symbol has been defined, then it is passed. Otherwise a string is passed the first time.

class SomeBug
  def respond_to_missing?(m, *)
    p m
    true
  end
end

if false then
  # uncomment to force to symbol--location doesn't matter, just the literal parse:
  # :aa
end

sd = SomeBug.new

# NOTE: single character strings do not show this behavior
sd.method("aa".to_sym)       # "aa" unless :aa uncommented above
sd.method("aa".to_sym)       # :aa
sd.method("bb".to_sym)       # "bb"
sd.method("bb".to_sym)       # :bb

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

  • Description updated (diff)

Good catch.
This behavior was to get rid of inadvertent symbol creation before symbol-GC,
so it is no longer needed.

Updated by Hanmac (Hans Mackowiak) over 5 years ago

@nobu (Nobuyoshi Nakada) should the value depending on the value used for method, or should respond_to_missing? always has Symbol as parameter?

i think the best would be to make it simple and always have it use Symbol

Actions #3

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r67185.


proc.c: call respond_to_missing? with a symbol

[ruby-core:91683] [Bug #15640]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0