diff options
| author | Nikita Vasilevsky <nikita.vasilevsky@shopify.com> | 2024-02-07 16:51:22 +0000 |
|---|---|---|
| committer | Kevin Newton <kddnewton@gmail.com> | 2024-02-13 09:39:28 -0500 |
| commit | d357d50f0a74409446f4cccec78593373f5adf2f (patch) | |
| tree | f07fff0c32a022ce8a59ee84fcb030767fdb7d7b | |
| parent | b662edf0a05c88e3c15a88aa48f48c7e4ede8597 (diff) | |
[PRISM] Fix lambda start column number
Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
| -rw-r--r-- | prism_compile.c | 7 | ||||
| -rw-r--r-- | test/ruby/test_compile_prism.rb | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/prism_compile.c b/prism_compile.c index 0f3b3966b8..ffa5cc77a2 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -2510,6 +2510,13 @@ pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_ scope->parameters = cast->parameters; scope->body = cast->body; scope->locals = cast->locals; + + if (cast->parameters != NULL) { + scope->base.location.start = cast->parameters->location.start; + } + else { + scope->base.location.start = cast->operator_loc.end; + } break; } case PM_MODULE_NODE: { diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index c48b7ac085..927ce3fa0e 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -1838,6 +1838,15 @@ end assert_prism_eval("-> { to_s }.call") end + def test_LambdaNode_with_multiline_args + assert_prism_eval(<<-CODE) + -> (a, + b) { + a + b + }.call(1, 2) + CODE + end + def test_ModuleNode assert_prism_eval("module M; end") assert_prism_eval("module M::N; end") |
