Skip to content

#caller returns `__send__' as one of the callers #603

@lkfken

Description

@lkfken
require 'pp'

module A
  def method_from_a
    caller
  end
end

class C
  include A
  def method_from_c
    __send__(:method_from_a)
  end
end

pp C.new.method_from_c

The code above if run under MRI Ruby 1.9.3 or 2.0, the output is:

["X:/ene/RubyScripts/1development/debug_caller/caller.rb:12:in `method_from_c'",
 "X:/ene/RubyScripts/1development/debug_caller/caller.rb:16:in `<top (required)>'",
 "-e:1:in `load'",
 "-e:1:in `<main>'"]

If the code above is running under JRuby 1.7.3, the output is:

["X:/ene/RubyScripts/1development/debug_caller/caller.rb:12:in `__send__'",
 "X:/ene/RubyScripts/1development/debug_caller/caller.rb:12:in `method_from_c'",
 "X:/ene/RubyScripts/1development/debug_caller/caller.rb:16:in `(root)'",
 "-e:1:in `load'",
 "-e:1:in `(root)'"]

The output from MRI Ruby and JRuby are obviously different.

I could add some additional logic to my code using something like RUBY_PLATFORM to find the immediate caller, but isn't a compatibility issue for JRUBY?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions