Project

General

Profile

Bug #9155

DelegateClass - ArgumentError: not delegated

Added by rhs (Russell Smith) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 2.1.0dev (2013-11-23 trunk 43807) [x86_64-darwin13.0]
[ruby-core:58572]

Description

Running the attached code gives ArgumentError: not delegated. It's unexpected as it worked on preview 1 and in 2.0.0. Error pasted below. https://gist.github.com/ukd1/9293c419a080d034f4bb - has sample code plus runs on 2.0.0p247 + 2.1.0-preview1 and 2.1.0-preview2

ArgumentError: not delegated
from /Users/russ/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/2.1.0/delegate.rb:384:in __getobj__'
from /Users/russ/.rvm/rubies/ruby-2.1.0-preview2/lib/ruby/2.1.0/delegate.rb:77:in
method_missing'
from (irb):5:in initialize'
from (irb):11:in
new'
from (irb):11
from /Users/russ/.rvm/rubies/ruby-2.1.0-preview2/bin/irb:11:in `'

sample.rb (171 Bytes) sample.rb sample file that's also in the gist in the issue rhs (Russell Smith), 11/26/2013 05:33 AM

Associated revisions

Revision fc4de123
Added by nobu (Nobuyoshi Nakada) over 4 years ago

delegate.rb: ignore unset target

  • lib/delegate.rb (Delegator#method_missing): ignore the target if not set, and delegate to global methods. [Bug #9155]
  • lib/delegate.rb (Delegator#respond_to_missing): ditto.
  • lib/delegate.rb (SimpleDelegator#getobj): yield and return if not delegated but a block is given, like as Hash#fetch.
  • lib/delegate.rb (DelegateClass#getobj): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 43984
Added by nobu (Nobuyoshi Nakada) over 4 years ago

delegate.rb: ignore unset target

  • lib/delegate.rb (Delegator#method_missing): ignore the target if not set, and delegate to global methods. [Bug #9155]
  • lib/delegate.rb (Delegator#respond_to_missing): ditto.
  • lib/delegate.rb (SimpleDelegator#getobj): yield and return if not delegated but a block is given, like as Hash#fetch.
  • lib/delegate.rb (DelegateClass#getobj): ditto.

Revision 43984
Added by nobu (Nobuyoshi Nakada) over 4 years ago

delegate.rb: ignore unset target

  • lib/delegate.rb (Delegator#method_missing): ignore the target if not set, and delegate to global methods. [Bug #9155]
  • lib/delegate.rb (Delegator#respond_to_missing): ditto.
  • lib/delegate.rb (SimpleDelegator#getobj): yield and return if not delegated but a block is given, like as Hash#fetch.
  • lib/delegate.rb (DelegateClass#getobj): ditto.

Revision 43984
Added by nobu (Nobuyoshi Nakada) over 4 years ago

delegate.rb: ignore unset target

  • lib/delegate.rb (Delegator#method_missing): ignore the target if not set, and delegate to global methods. [Bug #9155]
  • lib/delegate.rb (Delegator#respond_to_missing): ditto.
  • lib/delegate.rb (SimpleDelegator#getobj): yield and return if not delegated but a block is given, like as Hash#fetch.
  • lib/delegate.rb (DelegateClass#getobj): ditto.

Revision 43984
Added by nobu (Nobuyoshi Nakada) over 4 years ago

delegate.rb: ignore unset target

  • lib/delegate.rb (Delegator#method_missing): ignore the target if not set, and delegate to global methods. [Bug #9155]
  • lib/delegate.rb (Delegator#respond_to_missing): ditto.
  • lib/delegate.rb (SimpleDelegator#getobj): yield and return if not delegated but a block is given, like as Hash#fetch.
  • lib/delegate.rb (DelegateClass#getobj): ditto.

Revision 43984
Added by nobu (Nobuyoshi Nakada) over 4 years ago

delegate.rb: ignore unset target

  • lib/delegate.rb (Delegator#method_missing): ignore the target if not set, and delegate to global methods. [Bug #9155]
  • lib/delegate.rb (Delegator#respond_to_missing): ditto.
  • lib/delegate.rb (SimpleDelegator#getobj): yield and return if not delegated but a block is given, like as Hash#fetch.
  • lib/delegate.rb (DelegateClass#getobj): ditto.

Revision bcaec556
Added by nobu (Nobuyoshi Nakada) over 4 years ago

delegate.rb: keep special methods

  • lib/delegate.rb (Delegator): keep source information methods which start and end with '__'. [Bug #9155]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 44630
Added by nobu (Nobuyoshi Nakada) over 4 years ago

delegate.rb: keep special methods

  • lib/delegate.rb (Delegator): keep source information methods which start and end with '__'. [Bug #9155]

Revision 44630
Added by nobu (Nobuyoshi Nakada) over 4 years ago

delegate.rb: keep special methods

  • lib/delegate.rb (Delegator): keep source information methods which start and end with '__'. [Bug #9155]

Revision 44630
Added by nobu (Nobuyoshi Nakada) over 4 years ago

delegate.rb: keep special methods

  • lib/delegate.rb (Delegator): keep source information methods which start and end with '__'. [Bug #9155]

Revision 44630
Added by nobu (Nobuyoshi Nakada) over 4 years ago

delegate.rb: keep special methods

  • lib/delegate.rb (Delegator): keep source information methods which start and end with '__'. [Bug #9155]

Revision 44630
Added by nobu (Nobuyoshi Nakada) over 4 years ago

delegate.rb: keep special methods

  • lib/delegate.rb (Delegator): keep source information methods which start and end with '__'. [Bug #9155]

Revision 3da0a0ce
Added by naruse (Yui NARUSE) about 4 years ago

merge revision(s) 44630,44631: [Backport #9403]

* lib/delegate.rb (Delegator): keep source information methods
  which start and end with '__'.   [Bug #9155]
  which start and end with '__'.   [Bug #9403]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@44794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

History

#1 [ruby-core:58573] Updated by hsbt (Hiroshi SHIBATA) over 4 years ago

  • Assignee set to nobu (Nobuyoshi Nakada)
  • Priority changed from Normal to 5

#2 [ruby-core:58574] Updated by rhs (Russell Smith) over 4 years ago

hsbt (Hiroshi SHIBATA) yep that's where I found the issue - I thought I'd make it easier to replicate with the above code :)

#5 Updated by nobu (Nobuyoshi Nakada) over 4 years ago

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

This issue was solved with changeset r43984.
Russell, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


delegate.rb: ignore unset target

  • lib/delegate.rb (Delegator#method_missing): ignore the target if not set, and delegate to global methods. [Bug #9155]
  • lib/delegate.rb (Delegator#respond_to_missing): ditto.
  • lib/delegate.rb (SimpleDelegator#getobj): yield and return if not delegated but a block is given, like as Hash#fetch.
  • lib/delegate.rb (DelegateClass#getobj): ditto.

#6 Updated by rhs (Russell Smith) over 4 years ago

No problem, thanks for the fix.

Just a quick question - Simon fixed this on github; is this not the correct place to do a pull request / fix for a bug? If you can let us know, next time we'll do it through the correct channel.

Russ

#7 [ruby-core:58872] Updated by nobu (Nobuyoshi Nakada) over 4 years ago

I prefer here but a pull request on github is also a correct place.

The reason I didn't merge it is:

  • I didn't want to add another instance variable, and
  • more importantly, a subclass of Delegator/DelegateClass may not call super in its setobj method, and then the flag will be left unset.

Also available in: Atom PDF