Skip to content

Commit

Permalink
Fix location of global paths in certain constructs
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Nov 1, 2023
1 parent c97c20e commit 8fca14f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions spec/compiler/parser/parser_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2736,5 +2736,17 @@ module Crystal
node = Parser.parse(source).as(EnumDef).members.first
node_source(source, node).should eq("protected macro foo; end")
end

it "sets correct location of global path in class def" do
source = "class ::Foo; end"
node = Parser.parse(source).as(ClassDef).name
node_source(source, node).should eq("::Foo")
end

it "sets correct location of global path in annotation" do
source = "@[::Foo]"
node = Parser.parse(source).as(Annotation).path
node_source(source, node).should eq("::Foo")
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 @@ -5101,7 +5101,7 @@ module Crystal
global = true
end

path = parse_path(global, @token.location)
path = parse_path(global, location)
skip_space
path
end
Expand Down

0 comments on commit 8fca14f

Please sign in to comment.