Skip to content

Instantly share code, notes, and snippets.

@wanabe
Created August 9, 2012 22:56
Show Gist options
  • Select an option

  • Save wanabe/3308796 to your computer and use it in GitHub Desktop.

Select an option

Save wanabe/3308796 to your computer and use it in GitHub Desktop.
diff --git a/vm.c b/vm.c
index 6302153..76bfee4 100644
--- a/vm.c
+++ b/vm.c
@@ -412,6 +412,16 @@ vm_make_env_each(rb_thread_t * const th, rb_control_frame_t * const cfp,
nenvptr = &env->env[i - 1];
nenvptr[1] = envval; /* frame self */
+ if (envptr == endptr) {
+ rb_block_t *block = GC_GUARDED_PTR_REF(*nenvptr);
+ if (block && block->proc == 0) {
+ rb_proc_t *proc;
+ VALUE blockval = rb_vm_make_proc(th, block, rb_cProc);
+ GetProcPtr(blockval, proc);
+ *nenvptr = VM_ENVVAL_BLOCK_PTR(&proc->block);
+ }
+ }
+
/* reset ep in cfp */
cfp->ep = nenvptr;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment