aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-25 01:45:28 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-25 01:45:28 +0000
commit390667578fb46207532ae36539702eabdc93a687 (patch)
tree03490bdfb0e35f7452f8e664018c84ce933c19be /compile.c
parent3a3d1676558fee264e28ab52de2e1654b73d1d9a (diff)
downloadruby-390667578fb46207532ae36539702eabdc93a687.tar.gz
compile.c: refine error messages
* compile.c (rb_iseq_compile_node): raise compile error with exact iseq type name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/compile.c b/compile.c
index 767da7a3da..0d977fbebc 100644
--- a/compile.c
+++ b/compile.c
@@ -667,16 +667,17 @@ rb_iseq_compile_node(rb_iseq_t *iseq, NODE *node)
(*ifunc->func)(iseq, ret, ifunc->data);
}
else {
+ const char *m;
+#define INVALID_ISEQ_TYPE(type) \
+ ISEQ_TYPE_##type: m = #type; goto invalid_iseq_type
switch (iseq->body->type) {
- case ISEQ_TYPE_METHOD:
- case ISEQ_TYPE_CLASS:
- case ISEQ_TYPE_BLOCK:
- case ISEQ_TYPE_EVAL:
- case ISEQ_TYPE_MAIN:
- case ISEQ_TYPE_TOP:
- COMPILE_ERROR(ERROR_ARGS "compile/should not be reached: %s:%d",
- __FILE__, __LINE__);
- return COMPILE_NG;
+ case INVALID_ISEQ_TYPE(METHOD);
+ case INVALID_ISEQ_TYPE(CLASS);
+ case INVALID_ISEQ_TYPE(BLOCK);
+ case INVALID_ISEQ_TYPE(EVAL);
+ case INVALID_ISEQ_TYPE(MAIN);
+ case INVALID_ISEQ_TYPE(TOP);
+#undef INVALID_ISEQ_TYPE /* invalid iseq types end */
case ISEQ_TYPE_RESCUE:
iseq_set_exception_local_table(iseq);
CHECK(COMPILE(ret, "rescue", node));
@@ -690,7 +691,10 @@ rb_iseq_compile_node(rb_iseq_t *iseq, NODE *node)
CHECK(COMPILE(ret, "defined guard", node));
break;
default:
- COMPILE_ERROR(ERROR_ARGS "unknown scope");
+ COMPILE_ERROR(ERROR_ARGS "unknown scope: %d", iseq->body->type);
+ return COMPILE_NG;
+ invalid_iseq_type:
+ COMPILE_ERROR(ERROR_ARGS "compile/ISEQ_TYPE_%s should not be reached", m);
return COMPILE_NG;
}
}