diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-25 01:45:28 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-25 01:45:28 +0000 |
commit | 9db92694b06195679fe64f13a6610a7c25823fea (patch) | |
tree | 03490bdfb0e35f7452f8e664018c84ce933c19be /compile.c | |
parent | 0ba049256e1b8b17f68c45266396ed1e3976481b (diff) | |
download | ruby-9db92694b06195679fe64f13a6610a7c25823fea.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.c | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -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; } } |