Forum: Ruby-core [Bug #2824] Backtrace from Singleton Classes is Unclear

Posted by Run Paint Run Run (Guest)
on 2010-02-28 00:57
(Received via mailing list)
Bug #2824: Backtrace from Singleton Classes is Unclear
http://redmine.ruby-lang.org/issues/show/2824

Author: Run Paint Run Run
Status: Open, Priority: Low
Category: core
ruby -v: ruby 1.9.2dev (2010-02-19 trunk 26715) [i686-linux]

The backtrace from singleton classes needs a space between 'singleton' 
and 'class'.

$ ruby -e 'class << self; x; end'
-e:1:in `singletonclass': undefined local variable or method `x' for 
#<Class:#<Object:0x83efde8>> (NameError)
  from -e:1:in `<main>'

However, more useful would be to indicate _which_ object's singleton 
class raised the exception. This is particularly relevant for exceptions 
whose messages do not include the caller's #inspect output. For example, 
compare:

$ ruby -e 'class H; 1/0; end'
-e:1:in `/': divided by 0 (ZeroDivisionError)
  from -e:1:in `<class:H>'
  from -e:1:in `<main>'

$ ruby -e 'class << "c"; 1/0; end'
-e:1:in `/': divided by 0 (ZeroDivisionError)
  from -e:1:in `singletonclass'
  from -e:1:in `<main>'
Posted by Run Paint Run Run (Guest)
on 2010-09-02 16:45
Attachment: singleton-compile.c.patch (475 Bytes)
(Received via mailing list)
Issue #2824 has been updated by Run Paint Run Run.

File singleton-compile.c.patch added

The attached fixes the typo; improving the error message appears to 
require knowledge of YARV internals.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/2824
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.