summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/compile.c b/compile.c
index 30029ed98a..951d1c0076 100644
--- a/compile.c
+++ b/compile.c
@@ -2724,16 +2724,22 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret,
static VALUE
make_name_for_block(rb_iseq_t *iseq)
{
- if (iseq->parent_iseq == 0) {
- return rb_sprintf("block in %s", RSTRING_PTR(iseq->name));
- }
- else {
- int level = 1;
- rb_iseq_t *ip = iseq;
+ int level = 1;
+ rb_iseq_t *ip = iseq;
+
+ if (iseq->parent_iseq != 0) {
while (ip->local_iseq != ip) {
+ if (ip->type == ISEQ_TYPE_BLOCK) {
+ level++;
+ }
ip = ip->parent_iseq;
- level++;
}
+ }
+
+ if (level == 1) {
+ return rb_sprintf("block in %s", RSTRING_PTR(ip->name));
+ }
+ else {
return rb_sprintf("block (%d levels) in %s", level, RSTRING_PTR(ip->name));
}
}
@@ -5323,5 +5329,3 @@ rb_parse_in_eval(void)
{
return GET_THREAD()->parse_in_eval != 0;
}
-
-