diff --git a/imemo.c b/imemo.c index 346fae3b869ca0..2dd05b29f9df3b 100644 --- a/imemo.c +++ b/imemo.c @@ -167,11 +167,14 @@ rb_imemo_fields_clone(VALUE fields_obj) VALUE clone; if (rb_shape_too_complex_p(shape_id)) { - clone = rb_imemo_fields_new_complex(rb_imemo_fields_owner(fields_obj), 0); - RBASIC_SET_SHAPE_ID(clone, shape_id); st_table *src_table = rb_imemo_fields_complex_tbl(fields_obj); - st_table *dest_table = rb_imemo_fields_complex_tbl(clone); + + st_table *dest_table = xcalloc(1, sizeof(st_table)); + clone = rb_imemo_fields_new_complex_tbl(rb_imemo_fields_owner(fields_obj), dest_table); + st_replace(dest_table, src_table); + RBASIC_SET_SHAPE_ID(clone, shape_id); + st_foreach(dest_table, imemo_fields_complex_wb_i, (st_data_t)clone); } else { diff --git a/parse.y b/parse.y index 6fac3b8ec79760..00c5aef6d267c3 100644 --- a/parse.y +++ b/parse.y @@ -3026,13 +3026,13 @@ rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary) } ; -%rule mlhs(item) +%rule mlhs_items(item) : item { $$ = NEW_LIST($1, &@$); /*% ripper: mlhs_add!(mlhs_new!, $:1) %*/ } - | mlhs(item) ',' item + | mlhs_items(item) ',' item { $$ = list_append(p, $1, $3); /*% ripper: mlhs_add!($:1, $:3) %*/ @@ -3676,7 +3676,7 @@ mlhs_basic : mlhs_head $$ = NEW_MASGN($1, $3, &@$); /*% ripper: mlhs_add_star!($:1, $:3) %*/ } - | mlhs_head tSTAR mlhs_node ',' mlhs(mlhs_item) + | mlhs_head tSTAR mlhs_node ',' mlhs_items(mlhs_item) { $$ = NEW_MASGN($1, NEW_POSTARG($3,$5,&@$), &@$); /*% ripper: mlhs_add_post!(mlhs_add_star!($:1, $:3), $:5) %*/ @@ -3686,7 +3686,7 @@ mlhs_basic : mlhs_head $$ = NEW_MASGN($1, NODE_SPECIAL_NO_NAME_REST, &@$); /*% ripper: mlhs_add_star!($:1, Qnil) %*/ } - | mlhs_head tSTAR ',' mlhs(mlhs_item) + | mlhs_head tSTAR ',' mlhs_items(mlhs_item) { $$ = NEW_MASGN($1, NEW_POSTARG(NODE_SPECIAL_NO_NAME_REST, $4, &@$), &@$); /*% ripper: mlhs_add_post!(mlhs_add_star!($:1, Qnil), $:4) %*/ @@ -3696,7 +3696,7 @@ mlhs_basic : mlhs_head $$ = NEW_MASGN(0, $2, &@$); /*% ripper: mlhs_add_star!(mlhs_new!, $:2) %*/ } - | tSTAR mlhs_node ',' mlhs(mlhs_item) + | tSTAR mlhs_node ',' mlhs_items(mlhs_item) { $$ = NEW_MASGN(0, NEW_POSTARG($2,$4,&@$), &@$); /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $:2), $:4) %*/ @@ -3706,7 +3706,7 @@ mlhs_basic : mlhs_head $$ = NEW_MASGN(0, NODE_SPECIAL_NO_NAME_REST, &@$); /*% ripper: mlhs_add_star!(mlhs_new!, Qnil) %*/ } - | tSTAR ',' mlhs(mlhs_item) + | tSTAR ',' mlhs_items(mlhs_item) { $$ = NEW_MASGN(0, NEW_POSTARG(NODE_SPECIAL_NO_NAME_REST, $3, &@$), &@$); /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, Qnil), $:3) %*/ @@ -4917,17 +4917,17 @@ f_marg : f_norm_arg ; -f_margs : mlhs(f_marg) +f_margs : mlhs_items(f_marg) { $$ = NEW_MASGN($1, 0, &@$); /*% ripper: $:1 %*/ } - | mlhs(f_marg) ',' f_rest_marg + | mlhs_items(f_marg) ',' f_rest_marg { $$ = NEW_MASGN($1, $3, &@$); /*% ripper: mlhs_add_star!($:1, $:3) %*/ } - | mlhs(f_marg) ',' f_rest_marg ',' mlhs(f_marg) + | mlhs_items(f_marg) ',' f_rest_marg ',' mlhs_items(f_marg) { $$ = NEW_MASGN($1, NEW_POSTARG($3, $5, &@$), &@$); /*% ripper: mlhs_add_post!(mlhs_add_star!($:1, $:3), $:5) %*/ @@ -4937,7 +4937,7 @@ f_margs : mlhs(f_marg) $$ = NEW_MASGN(0, $1, &@$); /*% ripper: mlhs_add_star!(mlhs_new!, $:1) %*/ } - | f_rest_marg ',' mlhs(f_marg) + | f_rest_marg ',' mlhs_items(f_marg) { $$ = NEW_MASGN(0, NEW_POSTARG($1, $3, &@$), &@$); /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $:1), $:3) %*/