diff options
author | Matt Valentine-House <[email protected]> | 2024-02-08 15:28:05 +0000 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2024-02-13 21:19:12 -0500 |
commit | f70a4a03364f03432e35bf22402d6d1c7f2e40af (patch) | |
tree | 8a51fbe7371f99ed164247cd32eae64ecf3da137 | |
parent | 0285b533e95f54866febffda108c18be329aba55 (diff) |
[PRISM] yield is invalid inside eval
-rw-r--r-- | prism_compile.c | 9 |
1 files changed, 9 insertions, 0 deletions
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; |