diff --git a/parse.y b/parse.y index 067f45e6d6..03dd1c6f92 100644 --- a/parse.y +++ b/parse.y @@ -5149,7 +5149,7 @@ lambda : tLAMBDA[lpar] CMDARG_POP(); $args = args_with_numbered(p, $args, max_numparam, it_id); { - YYLTYPE loc = code_loc_gen(&@args, &@body); + YYLTYPE loc = code_loc_gen(&@lpar, &@body); $$ = NEW_LAMBDA($args, $body->node, &loc, &@lpar, &$body->opening_loc, &$body->closing_loc); nd_set_line(RNODE_LAMBDA($$)->nd_body, @body.end_pos.lineno); nd_set_line($$, @args.end_pos.lineno); diff --git a/prism_compile.c b/prism_compile.c index 77b940ce6c..36a0b6ce50 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -3284,13 +3284,6 @@ 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/spec/ruby/core/proc/source_location_spec.rb b/spec/ruby/core/proc/source_location_spec.rb index 69b4e2fd82..18f1ca274c 100644 --- a/spec/ruby/core/proc/source_location_spec.rb +++ b/spec/ruby/core/proc/source_location_spec.rb @@ -61,7 +61,7 @@ describe "Proc#source_location" do ruby_version_is("4.0") do proc { true }.source_location.should == [__FILE__, __LINE__, 11, __LINE__, 19] Proc.new { true }.source_location.should == [__FILE__, __LINE__, 15, __LINE__, 23] - -> { true }.source_location.should == [__FILE__, __LINE__, 8, __LINE__, 17] + -> { true }.source_location.should == [__FILE__, __LINE__, 6, __LINE__, 17] end end @@ -98,7 +98,7 @@ describe "Proc#source_location" do location.should == ["foo", 100] end ruby_version_is("4.0") do - location.should == ["foo", 100, 2, 100, 5] + location.should == ["foo", 100, 0, 100, 5] end end end diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index c7a946dec8..22ccbfb604 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -1230,7 +1230,7 @@ dummy args: nil body: (LAMBDA@1:0-2:3 - (SCOPE@1:2-2:3 + (SCOPE@1:0-2:3 tbl: [] args: (ARGS@1:2-1:2 diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb index 3cbb54306c..6a0dd9915e 100644 --- a/test/ruby/test_lambda.rb +++ b/test/ruby/test_lambda.rb @@ -276,7 +276,7 @@ class TestLambdaParameters < Test::Unit::TestCase end def test_do_lambda_source_location - exp = [__LINE__ + 1, 12, __LINE__ + 5, 7] + exp = [__LINE__ + 1, 10, __LINE__ + 5, 7] lmd = ->(x, y, z) do @@ -288,7 +288,7 @@ class TestLambdaParameters < Test::Unit::TestCase end def test_brace_lambda_source_location - exp = [__LINE__ + 1, 12, __LINE__ + 5, 5] + exp = [__LINE__ + 1, 10, __LINE__ + 5, 5] lmd = ->(x, y, z) {