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

Add location to result from macro method interpretation #15213

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

straight-shoota
Copy link
Member

When calling a macro method, the result is typically a newly created AST node. So in most cases, the location of the AST node should be the location of the call. There are some exceptions though. Some methods don't create new nodes, they are just getters for pre-existing ones (for example: Def#body returns the AST node of the body).
So if the returned node already has a location, we should not override it. Pre-existing nodes are typically created from parsing source code and thus should be expected to have a location.
I did not verify this for all cases, so this change has some potential for injecting a false location into an existing node becuase we're mutating the stored instance without cloning it. But I don't think there's a high risk for this, nor would this have a major effect. An incorrect location is worse than no location, but not much. And the fix for both is identical: make sure the correct location is used when the node is created.

This fixes the immediate bug in #15202, not the deeper issue with AST nodes missing location info being passed to LLVM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Module validation failed: inlinable function call in a function with debug info must have a !dbg location
1 participant