ruby-changes:25563
From: nobu <ko1@a...>
Date: Sun, 11 Nov 2012 15:38:27 +0900 (JST)
Subject: [ruby-changes:25563] nobu:r37620 (trunk): hash.c: refine error messages
nobu 2012-11-11 15:38:17 +0900 (Sun, 11 Nov 2012) New Revision: 37620 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37620 Log: hash.c: refine error messages * hash.c (rb_hash_s_create): refine error messages. * error.c (rb_builtin_class_name): share for above. Modified files: trunk/ChangeLog trunk/common.mk trunk/error.c trunk/hash.c trunk/internal.h Index: ChangeLog =================================================================== --- ChangeLog (revision 37619) +++ ChangeLog (revision 37620) @@ -1,3 +1,9 @@ +Sun Nov 11 15:38:14 2012 Nobuyoshi Nakada <nobu@r...> + + * hash.c (rb_hash_s_create): refine error messages. + + * error.c (rb_builtin_class_name): share for above. + Sun Nov 11 15:12:18 2012 Shugo Maeda <shugo@r...> * eval.c (top_using): remove Kernel#using, and add main.using instead. Index: common.mk =================================================================== --- common.mk (revision 37619) +++ common.mk (revision 37620) @@ -662,7 +662,7 @@ {$(VPATH)}debug.h {$(VPATH)}internal.h {$(VPATH)}constant.h \ {$(VPATH)}thread.h hash.$(OBJEXT): {$(VPATH)}hash.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h \ - $(ENCODING_H_INCLUDES) + $(ENCODING_H_INCLUDES) {$(VPATH)}internal.h inits.$(OBJEXT): {$(VPATH)}inits.c $(RUBY_H_INCLUDES) \ {$(VPATH)}internal.h io.$(OBJEXT): {$(VPATH)}io.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \ Index: hash.c =================================================================== --- hash.c (revision 37619) +++ hash.c (revision 37620) @@ -15,6 +15,7 @@ #include "ruby/st.h" #include "ruby/util.h" #include "ruby/encoding.h" +#include "internal.h" #include <errno.h> #ifdef __APPLE__ @@ -392,11 +393,14 @@ hash = hash_alloc(klass); for (i = 0; i < RARRAY_LEN(tmp); ++i) { - VALUE v = rb_check_array_type(RARRAY_PTR(tmp)[i]); + VALUE e = RARRAY_PTR(tmp)[i]; + VALUE v = rb_check_array_type(e); VALUE key, val = Qnil; if (NIL_P(v)) { - rb_raise(rb_eArgError, "wrong element type (expected array)"); + rb_raise(rb_eArgError, "wrong element type %s at %ld (expected array)", + rb_builtin_class_name(e), i); + } switch (RARRAY_LEN(v)) { default: Index: error.c =================================================================== --- error.c (revision 37619) +++ error.c (revision 37620) @@ -432,8 +432,9 @@ return 0; } -static const char * -builtin_class_name(VALUE x) +#define builtin_class_name rb_builtin_class_name +const char * +rb_builtin_class_name(VALUE x) { const char *etype; Index: internal.h =================================================================== --- internal.h (revision 37619) +++ internal.h (revision 37620) @@ -95,6 +95,7 @@ VALUE rb_check_backtrace(VALUE); NORETURN(void rb_async_bug_errno(const char *,int)); const char *rb_builtin_type_name(int t); +const char *rb_builtin_class_name(VALUE x); /* eval_error.c */ void ruby_error_print(void); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/