Project

General

Profile

Actions

Feature #2824

closed

Backtrace from Singleton Classes is Unclear

Added by runpaint (Run Paint Run Run) almost 15 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
[ruby-core:28368]

Description

=begin
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 `'

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

$ ruby -e 'class << "c"; 1/0; end'
-e:1:in /': divided by 0 (ZeroDivisionError) from -e:1:in singletonclass'
from -e:1:in `'
=end


Files

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

Also available in: Atom PDF

Like0
Like0Like0Like0