-
Notifications
You must be signed in to change notification settings - Fork 8k
Improve assignment type inference #21143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve assignment type inference #21143
Conversation
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
src/System.Management.Automation/engine/parser/TypeInferenceVisitor.cs
Outdated
Show resolved
Hide resolved
| $res.Count | Should -Be 1 | ||
| $res.Name | Should -Be "System.String" | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see tests cases from the PR description:
This will fix the type inference for multiple variable assignments like: $Test1 = [string]$Test2 = $Test3 = $Test4 = 10 and also variables assigned with parentheses: $Test1 = ($Test2 = ls)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because the examples from the description are practical examples of where the effect of this change can be felt. However, since the API lets us specify the exact Ast we want to infer, there is no need for the practical examples in the tests as we can make them more specific.
…sitor.cs Co-authored-by: Ilya <darpa@yandex.ru>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
📣 Hey @MartinGC94, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗 https://aka.ms/PSRepoFeedback |
PR Summary
Fix the assignment statement type inference to correctly infer its type based on the right side statement, rather than the left.
PR Context
This will fix the type inference for multiple variable assignments like:
$Test1 = [string]$Test2 = $Test3 = $Test4 = 10and also variables assigned with parentheses:$Test1 = ($Test2 = ls)PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).