Repository navigation
Respect scope qualifiers when resolving local functions - #16
Merged
jessehouwing merged 2 commits intoOct 8, 2026
Merged
jessehouwing merged 2 commits into
jessehouwing merged 2 commits into
Conversation
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.
PR Summary
Scoped function declarations currently fall back to the installed command's metadata. For example,
PSUseCorrectCasingsuggestsPathfor this call even though the function declaresPATH:This uses the existing function-name normalizer for the four supported scope prefixes and preserves their visibility: local declarations stay in their containing scope, private declarations stay in their exact defining scope, and script/global declarations remain visible across the script. Directly invoked child blocks are distinguished from dot-sourced blocks and scriptblock arguments. Module-qualified cmdlet calls still resolve against the module.
The dot-source collector also excludes ordinary local/private definitions nested in a child scope. It previously flattened those definitions into the file group and could hide a legitimate diagnostic in another file. Scoped declarations that are visible in the shared scope still reach the other dot-sourced files.
This targets your branch for PowerShell/PSScriptAnalyzer#2206, based on
3f5bf19. It is independent of the suppression-scan contribution in #15. No public API, dependency or execution-order model is added; this remains conservative static command resolution.Native
net8andnet462builds passed. The selected engine, casing and formatter suites passed 82 tests on both PowerShell 7.6.6 and Windows PowerShell 5.1, with two existing skips. All 25 new cases run; the unchanged baseline fails 22 of them. Seven isolated runtime probes confirm scope behavior on both hosts. Validation covers analyzer and formatter output, mandatory-parameter lookups, private child-scope boundaries, dot-source groups, unrelated cmdlets and analysis isolation.Final comparisons preserve the formatted bytes and complete diagnostic details for Locksmith (244 diagnostics), PSSharedGoods (308) and PSWriteHTML (857), with no rule errors. An independent review and targeted confirmation covered the scope boundaries and dot-source filtering.
PR Checklist
.cs,.ps1and.psm1files have the correct copyright header