From 8bc6fff32208ac60b8421458fe2337ee6599c5be Mon Sep 17 00:00:00 2001 From: Jenny Shen Date: Sat, 3 Feb 2024 19:17:28 -0500 Subject: [PATCH] [PRISM] Do not optimize safe navigation aref Co-authored-by: Peter Zhu --- prism_compile.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/prism_compile.c b/prism_compile.c index 68ce705f70..b9838398a1 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -4166,7 +4166,9 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, ADD_INSN2(ret, &dummy_line_node, opt_str_freeze, str, new_callinfo(iseq, idFreeze, 0, 0, NULL, FALSE)); } } - else if (method_id == idAREF && call_node->arguments && + else if (method_id == idAREF && + !PM_NODE_FLAG_P(call_node, PM_CALL_NODE_FLAGS_SAFE_NAVIGATION) && + call_node->arguments && PM_NODE_TYPE_P((pm_node_t *)call_node->arguments, PM_ARGUMENTS_NODE) && ((pm_arguments_node_t *)call_node->arguments)->arguments.size == 1 && PM_NODE_TYPE_P(((pm_arguments_node_t *)call_node->arguments)->arguments.nodes[0], PM_STRING_NODE) &&