Add NameError#name. Fix NameError.new and NameError.initialize. Enable 2nd argument for NameError.new in C API.

This commit is contained in:
Masaki Muranaka
2013-04-04 16:23:38 +09:00
parent 1efb1bbaff
commit edd0a62106
2 changed files with 12 additions and 2 deletions
+10
View File
@@ -38,6 +38,16 @@ end
# ISO 15.2.31
class NameError < StandardError
attr_accessor :name
def new(message="NameError", name=nil)
initialize(message, name)
end
def initialize(message=nil, name=nil)
@name = name
super(message)
end
end
# ISO 15.2.32
+2 -2
View File
@@ -306,8 +306,8 @@ mrb_name_error(mrb_state *mrb, mrb_sym id, const char *fmt, ...)
argv[0] = mrb_vformat(mrb, fmt, args);
va_end(args);
argv[1] = mrb_symbol_value(id); /* ignore now */
exc = mrb_class_new_instance(mrb, 1, argv, E_NAME_ERROR);
argv[1] = mrb_symbol_value(id);
exc = mrb_class_new_instance(mrb, 2, argv, E_NAME_ERROR);
mrb_exc_raise(mrb, exc);
}