Skip to content

Commit b42c839

Browse files
tekknolagitenderlove
authored andcommitted
Don't support blockarg in opt_new
We don't calculate the correct argc so the bookkeeping slot is something else (unexpected) instead of Qnil (expected).
1 parent 6052b12 commit b42c839

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

insns.def

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,11 +916,13 @@ opt_new
916916
VALUE argc = vm_ci_argc(cd->ci);
917917
VALUE val = TOPN(argc);
918918

919+
// The bookkeeping slot should be empty.
920+
RUBY_ASSERT(TOPN(argc + 1) == Qnil);
921+
919922
if (vm_method_cfunc_is(GET_ISEQ(), cd, val, rb_class_new_instance_pass_kw) && !(ruby_vm_event_flags & ISEQ_TRACE_EVENTS)) {
920923
RB_DEBUG_COUNTER_INC(opt_new_hit);
921924
val = rb_obj_alloc(val);
922925
TOPN(argc) = val;
923-
RUBY_ASSERT(TOPN(argc + 1) == Qnil);
924926
TOPN(argc + 1) = val;
925927
}
926928
else {

prism_compile.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3722,7 +3722,8 @@ pm_compile_call(rb_iseq_t *iseq, const pm_call_node_t *call_node, LINK_ANCHOR *c
37223722

37233723
bool inline_new = ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction &&
37243724
method_id == rb_intern("new") &&
3725-
call_node->block == NULL;
3725+
call_node->block == NULL &&
3726+
(flags & VM_CALL_ARGS_BLOCKARG) == 0;
37263727

37273728
if (inline_new) {
37283729
if (LAST_ELEMENT(ret) == opt_new_prelude) {

0 commit comments

Comments
 (0)