@@ -10473,6 +10473,12 @@ compile_shareable_literal_constant(rb_iseq_t *iseq, LINK_ANCHOR *ret, enum rb_pa
1047310473 * shareable_literal_p = 0 ;
1047410474 return COMPILE_OK ;
1047510475 }
10476+ for (NODE * n = RNODE_HASH (node )-> nd_head ; n ; n = RNODE_LIST (RNODE_LIST (n )-> nd_next )-> nd_next ) {
10477+ if (!RNODE_LIST (n )-> nd_head ) {
10478+ // If the hash node have a keyword splat, fall back to the default case.
10479+ goto compile_shareable ;
10480+ }
10481+ }
1047610482
1047710483 INIT_ANCHOR (anchor );
1047810484 lit = rb_hash_new ();
@@ -10482,25 +10488,21 @@ compile_shareable_literal_constant(rb_iseq_t *iseq, LINK_ANCHOR *ret, enum rb_pa
1048210488 int shareable_literal_p2 ;
1048310489 NODE * key = RNODE_LIST (n )-> nd_head ;
1048410490 NODE * val = RNODE_LIST (RNODE_LIST (n )-> nd_next )-> nd_head ;
10485- if (key ) {
10486- CHECK (compile_shareable_literal_constant_next (key , anchor , & key_val , & shareable_literal_p2 ));
10487- if (shareable_literal_p2 ) {
10488- /* noop */
10489- }
10490- else if (RTEST (lit )) {
10491- rb_hash_clear (lit );
10492- lit = Qfalse ;
10493- }
10491+ CHECK (compile_shareable_literal_constant_next (key , anchor , & key_val , & shareable_literal_p2 ));
10492+ if (shareable_literal_p2 ) {
10493+ /* noop */
1049410494 }
10495- if (val ) {
10496- CHECK (compile_shareable_literal_constant_next (val , anchor , & value_val , & shareable_literal_p2 ));
10497- if (shareable_literal_p2 ) {
10498- /* noop */
10499- }
10500- else if (RTEST (lit )) {
10501- rb_hash_clear (lit );
10502- lit = Qfalse ;
10503- }
10495+ else if (RTEST (lit )) {
10496+ rb_hash_clear (lit );
10497+ lit = Qfalse ;
10498+ }
10499+ CHECK (compile_shareable_literal_constant_next (val , anchor , & value_val , & shareable_literal_p2 ));
10500+ if (shareable_literal_p2 ) {
10501+ /* noop */
10502+ }
10503+ else if (RTEST (lit )) {
10504+ rb_hash_clear (lit );
10505+ lit = Qfalse ;
1050410506 }
1050510507 if (RTEST (lit )) {
1050610508 if (!UNDEF_P (key_val ) && !UNDEF_P (value_val )) {
@@ -10516,6 +10518,8 @@ compile_shareable_literal_constant(rb_iseq_t *iseq, LINK_ANCHOR *ret, enum rb_pa
1051610518 }
1051710519
1051810520 default :
10521+
10522+ compile_shareable :
1051910523 if (shareable == rb_parser_shareable_literal &&
1052010524 (SHAREABLE_BARE_EXPRESSION || level > 0 )) {
1052110525 CHECK (compile_ensure_shareable_node (iseq , ret , dest , node ));
@@ -10529,7 +10533,7 @@ compile_shareable_literal_constant(rb_iseq_t *iseq, LINK_ANCHOR *ret, enum rb_pa
1052910533 return COMPILE_OK ;
1053010534 }
1053110535
10532- /* Array or Hash */
10536+ /* Array or Hash that does not have keyword splat */
1053310537 if (!lit ) {
1053410538 if (nd_type (node ) == NODE_LIST ) {
1053510539 ADD_INSN1 (anchor , node , newarray , INT2FIX (RNODE_LIST (node )-> as .nd_alen ));
0 commit comments