Feature #2824

Backtrace from Singleton Classes is Unclear

Added by Run Paint Run Run almost 2 years ago. Updated 10 months ago.

[ruby-core:28368]
Status:Open Start date:02/28/2010
Priority:Low Due date:
Assignee:- % Done:

0%

Category:core
Target version:2.0.0

Description

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>'

singleton-compile.c.patch (475 Bytes) Run Paint Run Run, 09/02/2010 11:45 pm

History

Updated by Kazuhiro NISHIYAMA almost 2 years ago

  • Target version set to 2.0.0

Updated by Run Paint Run Run over 1 year ago

The attached fixes the typo; improving the error message appears to require knowledge of YARV internals.

Also available in: Atom PDF