ruby-changes:62072
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:08:47 +0900 (JST)
Subject: [ruby-changes:62072] 2bfac015d3 (master): proc_binding: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=2bfac015d3 From 2bfac015d3742408d0c4d9f2220413992d0e49c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Tue, 16 Jun 2020 12:24:30 +0900 Subject: proc_binding: do not goto into a branch I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. diff --git a/proc.c b/proc.c index ee4ca9a..2780630 100644 --- a/proc.c +++ b/proc.c @@ -3229,8 +3229,6 @@ proc_binding(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L3229 GetProcPtr(block->as.proc, proc); block = &proc->block; goto again; - case block_type_symbol: - goto error; case block_type_ifunc: { const struct vm_ifunc *ifunc = block->as.captured.code.ifunc; @@ -3247,12 +3245,11 @@ proc_binding(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L3245 RB_OBJ_WRITE(env, &env->iseq, empty); break; } - else { - error: - rb_raise(rb_eArgError, "Can't create Binding from C level Proc"); - return Qnil; - } } + /* FALLTHROUGH */ + case block_type_symbol: + rb_raise(rb_eArgError, "Can't create Binding from C level Proc"); + UNREACHABLE_RETURN(Qnil); } bindval = rb_binding_alloc(rb_cBinding); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/