Fix rule error location reporting in the presence of symbolic macros
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
Errors that occur within a rule have messages prefixed by the rule's location. Currently, for rules that are not in a symbolic macro, this location is taken to be the outermost stack frame, i.e. the line on the `BUILD` file that caused the rule to be declared (rather than a line buried in some deep `.bzl` logic). But for rules inside a symbolic macro, we use the outermost stack frame of the innermost symbolic macro.
This is inconsistent and arbitrary -- either we should always use the `BUILD` file location, or we should always use the innermost stack frame (maybe confusing in some circumstances), or we should provide more information up to possibly the complete call stack (though that wouldn't fit in the current error message format).
The location logic in question lives in `TargetDefinitionContext#createRule`.
Contributor guide
Research direction
Start at TargetDefinitionContext#createRule, where the rule error location is selected. Compare the existing behavior for ordinary rules and rules inside symbolic macros, then determine and document a consistent location policy. Done means the chosen policy is implemented and both cases report locations consistently, with relevant coverage added.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100