Skip to content

Fix location of MacroExpression nodes#15524

Merged
straight-shoota merged 2 commits intocrystal-lang:masterfrom
Sija:patch-15
Feb 27, 2025
Merged

Fix location of MacroExpression nodes#15524
straight-shoota merged 2 commits intocrystal-lang:masterfrom
Sija:patch-15

Conversation

@Sija
Copy link
Contributor

@Sija Sija commented Feb 25, 2025

Fixes incorrect location of MacroExpression nodes, due to the fact that:

  1. @token.location was being called too late, since parse_macro_expression was advancing the position before the assignment
  2. and OTOH token_end_location was being called too early

Before this PR:

node         # => {{ type }}
location     # => src/random.cr:320:45
end_location # => src/random.cr:320:45

source_between(location, end_location) # => "}"

after:

node         # => {{ type }}
location     # => src/random.cr:320:39
end_location # => src/random.cr:320:46

source_between(location, end_location) # => "{{type}}"

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:parser labels Feb 25, 2025
@ysbaddaden ysbaddaden added this to the 1.16.0 milestone Feb 26, 2025
@straight-shoota straight-shoota merged commit 07552f6 into crystal-lang:master Feb 27, 2025
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants