Browse files

hash.c: refine error messages

* hash.c (rb_hash_s_create): refine error messages.
* error.c (rb_builtin_class_name): share for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 10ba3bd commit 5a5a86cc527946fb40f241377179b0723f2348db @nobu nobu committed Nov 11, 2012
Showing with 17 additions and 5 deletions.
  1. +6 −0 ChangeLog
  2. +1 −1 common.mk
  3. +3 −2 error.c
  4. +6 −2 hash.c
  5. +1 −0 internal.h
View
6 ChangeLog
@@ -1,3 +1,9 @@
+Sun Nov 11 15:38:14 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* eval.c (top_using): remove Kernel#using, and add main.using instead.
View
2 common.mk
@@ -662,7 +662,7 @@ gc.$(OBJEXT): {$(VPATH)}gc.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
{$(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 \
View
5 error.c
@@ -432,8 +432,9 @@ rb_builtin_type_name(int t)
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;
View
8 hash.c
@@ -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 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
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:
View
1 internal.h
@@ -95,6 +95,7 @@ NORETURN(PRINTF_ARGS(void rb_compile_bug(const char*, int, const char*, ...), 3,
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);

0 comments on commit 5a5a86c

Please sign in to comment.