Repository navigation
fix(program): prune provenance spans that do not resolve in attached file source - #410
Merged
Merged
Conversation
…file source A provider map can record a span whose extent is not a position in the authored member: OPY macro expansion attributes expanded tokens by shifting them onto the invocation site, so a recorded end column runs past the authored line (wrightkit/wright#583, e.g. bastion's composition/bootstrap.opy rule spans). Once set_file_source retains that member's text, Program::validate bounds-checks every provenance span against the document and the stale position fails the whole load with invalid-span. Attaching text now audits provenance the same way record_identities retires displaced records: a span that does not resolve inside the retained document is cleared so the node survives with no span rather than a wrong one. Consumers keep every span that is still addressable, and lint fix extents derived from surviving spans stay trustworthy.
2 tasks done
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.
Summary
Program::set_file_sourceretains a member's authored text after a source map rebinds the file table. A provider map can record a span whose extent is not a position in that text — OPY macro expansion attributes expanded tokens by shifting them onto the invocation site, so a recorded end column can run past the authored line (wrightkit/wright#583: bastion'scomposition/bootstrap.opyrule spans, overwatch-ai-pve'sutilities/hero_switch.opyconditions). Once source is retained,Program::validatebounds-checks every provenance span and the stale position fails the whole load withinvalid-span.Attaching text now audits provenance the same way
record_identitiesretires displaced records: a span that does not resolve inside the retained document is cleared, so the node survives with no span rather than a wrong one. Consumers keep every span that is still addressable; lint fix extents derived from surviving spans stay trustworthy.The underlying opy-rs macro-attribution defect is filed separately.
Test plan
file_source_retention_prunes_spans_outside_the_text— attached text shorter than the recorded rule span clears it; spans that fit survive;Program::validatepassescompile,lint,analyzeall succeed where the 1.12.0 build failed withinvalid-spancargo fmt --all -- --check,cargo clippy -p workshop-rs --all-targets -- -D warnings,cargo test -p workshop-rs