Skip to content

Exclude outvariable assignments within the same CommandAst when inferring variables - #25224

Merged
Ilya (iSazonov) merged 3 commits into
PowerShell:masterfrom
MartinGC94:ImproveOutVarInference
Mar 26, 2025
Merged

Ilya (iSazonov) merged 3 commits into
PowerShell:masterfrom
MartinGC94:ImproveOutVarInference

Conversation

@MartinGC94

Copy link
Copy Markdown
Contributor

PR Summary

This PR updates the variable type inference to ignore the assignments made within the same CommandAst as the variable that is being inferred. This fixes scenarios like: gci 2>Variable:Demo -Path ($Demo.<Tab>) where it would previously infer that $Demo was an ErrorRecord even though it wouldn't be assigned yet during the parameter binding.

PR Context

Pulled out another PR, see: #25206 (comment)

PR Checklist

@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Mar 24, 2025
@iSazonov

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

@iSazonov Ilya (iSazonov) self-assigned this Mar 24, 2025
@iSazonov

Copy link
Copy Markdown
Collaborator

/azp run

@iSazonov

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

@iSazonov

Copy link
Copy Markdown
Collaborator

MartinGC94 Please resolve merge conflicts.

@iSazonov

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

@iSazonov
Ilya (iSazonov) enabled auto-merge (squash) March 26, 2025 17:15
@iSazonov
Ilya (iSazonov) merged commit 0c96975 into PowerShell:master Mar 26, 2025
@microsoft-github-policy-service

microsoft-github-policy-service Bot commented Mar 26, 2025 •

Copy link
Copy Markdown
Contributor

📣 Hey MartinGC94, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

Sysoiev-Yurii pushed a commit to Sysoiev-Yurii/PowerShell that referenced this pull request May 12, 2025
SIRMARGIN pushed a commit to SIRMARGIN/PowerShell that referenced this pull request Dec 12, 2025
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants