Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Crystal::Path#to_macro_id for global path #14490

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions spec/compiler/macro/macro_methods_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ module Crystal
it "expands macro with id call on number" do
assert_macro "{{x.id}}", %(1), {x: 1.int32}
end

it "expands macro with id call on path" do
assert_macro "{{x.id}}", %(Foo), {x: Path.new("Foo")}
end

it "expands macro with id call on global path" do
assert_macro "{{x.id}}", %(::Foo), {x: Path.new("Foo", global: true)}
end
end

it "executes == on numbers (true)" do
Expand Down
6 changes: 5 additions & 1 deletion src/compiler/crystal/macros/methods.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2388,7 +2388,11 @@ module Crystal
end

def to_macro_id
@names.join "::"
String.build do |io|
io << "::" if global?

@names.join(io, "::")
end
end
end

Expand Down
Loading