diff options
author | Kevin Newton <[email protected]> | 2024-05-02 14:06:33 -0400 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2024-05-02 15:16:15 -0400 |
commit | e34c131ce8c25a5f70d24f85787728e08539d90c (patch) | |
tree | 8eb89afa38807e53acdd6d697201acf354b6e8f1 /prism_compile.c | |
parent | c681af3e5d36fb36c76e05b5d822131f28ed9de7 (diff) |
[PRISM] Disallow redundant returns from being line events
Diffstat (limited to 'prism_compile.c')
-rw-r--r-- | prism_compile.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/prism_compile.c b/prism_compile.c index caa9eb0052..f05f92f4ee 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -4542,14 +4542,16 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, const pm_line_column_t location = PM_NODE_START_LINE_COLUMN(parser, node); int lineno = (int) location.line; - if (PM_NODE_FLAG_P(node, PM_NODE_FLAG_NEWLINE) && ISEQ_COMPILE_DATA(iseq)->last_line != lineno) { - int event = RUBY_EVENT_LINE; + if (!PM_NODE_TYPE_P(node, PM_RETURN_NODE) || !PM_NODE_FLAG_P(node, PM_RETURN_NODE_FLAGS_REDUNDANT) || ((const pm_return_node_t *) node)->arguments != NULL) { + if (PM_NODE_FLAG_P(node, PM_NODE_FLAG_NEWLINE) && ISEQ_COMPILE_DATA(iseq)->last_line != lineno) { + int event = RUBY_EVENT_LINE; - ISEQ_COMPILE_DATA(iseq)->last_line = lineno; - if (ISEQ_COVERAGE(iseq) && ISEQ_LINE_COVERAGE(iseq)) { - event |= RUBY_EVENT_COVERAGE_LINE; + ISEQ_COMPILE_DATA(iseq)->last_line = lineno; + if (ISEQ_COVERAGE(iseq) && ISEQ_LINE_COVERAGE(iseq)) { + event |= RUBY_EVENT_COVERAGE_LINE; + } + PUSH_TRACE(ret, event); } - PUSH_TRACE(ret, event); } switch (PM_NODE_TYPE(node)) { |