Fix prepend_workspace_prefix to use visited value instead of closure root#5513
Open
simonfaltum wants to merge 2 commits into
Open
Fix prepend_workspace_prefix to use visited value instead of closure root#5513simonfaltum wants to merge 2 commits into
simonfaltum wants to merge 2 commits into
Conversation
…root The MapByPattern callback referenced the closure variable v (the root config value) instead of the visited value pv. The type-mismatch error always reported "got map", and rewritten paths were assigned the root document's locations, so later diagnostics pointed at the wrong line. Co-authored-by: Isaac
Contributor
Waiting for approvalBased on git history, these people are best suited to review:
Eligible reviewers: Suggestions based on git history. See OWNERS for ownership rules. |
Collaborator
|
Commit: aeca96c
22 interesting tests: 15 SKIP, 7 RECOVERED
Top 30 slowest tests (at least 2 minutes):
|
Co-authored-by: Isaac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Found during a full-repo review of the CLI. The
MapByPatterncallback inbundle/config/mutator/prepend_workspace_prefix.goreferenced the closure variablev(the root config value) instead of the visited valuepv. Two consequences: the type-mismatch error always reported "got map" regardless of the actual kind, and every rewritten workspace path was assigned the root document's locations instead of its own. Any later diagnostic referring to one of these paths pointed at the wrong place in the config.Changes
Before, rewritten workspace paths lost their original source locations and the error message always claimed the value was a map; now both come from the value actually being visited. Two one-word fixes in the callback: the error uses
pv.Kind()and the rewritten value usespv.Locations(). Added a unit test that sets a location onworkspace.root_pathand asserts it survives the rewrite.Test plan
TestPrependWorkspacePrefixPreservesLocations(verified it fails on the previous code and passes with the fix)go test ./bundle/config/mutator/TestAccept/bundle/variables/prepend-workspace-var./task fmt-q,./task lint-q,./task checksThis pull request and its description were written by Isaac.