diff options
author | Nikita Vasilevsky <nikita.vasilevsky@shopify.com> | 2024-02-01 18:04:29 +0000 |
---|---|---|
committer | Kevin Newton <kddnewton@gmail.com> | 2024-02-01 15:23:39 -0500 |
commit | c7fe3ecb49784fcc6a9780f89880d758cd272449 (patch) | |
tree | 035cce74f01cb77294411ac2264351c28bcf8c52 /prism_compile.c | |
parent | e4e5a1b4ee3f04a69c62c1cc067f65245b469321 (diff) |
[prism] Use block opening line as `source_location` line of lambda
There are several prism tests failing related to the `source_location`
for lambda returning line of the operator (`->`)
while original parser execution results in `source_location` line
pointing to the block opening location (`{` or `do`)
This commit changes `PM_LAMBDA_NODE` compilation case
to use block opening location instead of the whole node (operator)
opening location to get the line number to build block iseq
Diffstat (limited to 'prism_compile.c')
-rw-r--r-- | prism_compile.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/prism_compile.c b/prism_compile.c index 595d3b8e78..58a71fcfdb 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -5564,9 +5564,14 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, return; } case PM_LAMBDA_NODE: { + const pm_lambda_node_t *cast = (const pm_lambda_node_t *) node; + pm_scope_node_t next_scope_node; pm_scope_node_init(node, &next_scope_node, scope_node, parser); - const rb_iseq_t *block = NEW_CHILD_ISEQ(&next_scope_node, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, lineno); + + int opening_lineno = (int) pm_newline_list_line_column(&parser->newline_list, cast->opening_loc.start).line; + + const rb_iseq_t *block = NEW_CHILD_ISEQ(&next_scope_node, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, opening_lineno); pm_scope_node_destroy(&next_scope_node); VALUE argc = INT2FIX(0); |