Skip to content

Commit

Permalink
Add missing location of argument in named tuple type
Browse files Browse the repository at this point in the history
`foo: Bar` in `x : {foo: Bar}`
  • Loading branch information
FnControlOption committed May 10, 2023
1 parent 6066e3c commit 4b2e9fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions spec/compiler/parser/parser_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2601,5 +2601,11 @@ module Crystal
node = Parser.parse(source).as(MultiAssign).targets[1]
node_source(source, node).should eq("*bar")
end

it "sets correct location of argument in named tuple type" do
source = "x : {foo: Bar}"
node = Parser.parse(source).as(TypeDeclaration).declared_type.as(Generic).named_args.not_nil![0]
node_source(source, node).should eq("foo: Bar")
end
end
end
2 changes: 1 addition & 1 deletion src/compiler/crystal/syntax/parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5157,7 +5157,7 @@ module Crystal
type = parse_bare_proc_type
skip_space

named_args << NamedArgument.new(name, type)
named_args << NamedArgument.new(name, type).at(name_location).at_end(type)

if @token.type.op_comma?
next_token_skip_space_or_newline
Expand Down

0 comments on commit 4b2e9fb

Please sign in to comment.