From f70a4a03364f03432e35bf22402d6d1c7f2e40af Mon Sep 17 00:00:00 2001 From: Matt Valentine-House Date: Thu, 8 Feb 2024 15:28:05 +0000 Subject: [PATCH] [PRISM] yield is invalid inside eval --- prism_compile.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/prism_compile.c b/prism_compile.c index 9cee340c0e..095799db9b 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -7960,6 +7960,15 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, case PM_YIELD_NODE: { pm_yield_node_t *yield_node = (pm_yield_node_t *)node; + switch (ISEQ_BODY(ISEQ_BODY(iseq)->local_iseq)->type) { + case ISEQ_TYPE_TOP: + case ISEQ_TYPE_MAIN: + case ISEQ_TYPE_CLASS: + COMPILE_ERROR(ERROR_ARGS "Invalid yield"); + return; + default: /* valid */; + } + int flags = 0; struct rb_callinfo_kwarg *keywords = NULL;