- Notifications
You must be signed in to change notification settings - Fork7.7k
Update Named and Statement block type inference to not consider AssignmentStatements and Increment/decrement operators as part of their output#21137
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…Statements as part of their output
This PR has Quantification details
Why proper sizing of changes mattersOptimal 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) |
This PR has Quantification details
Why proper sizing of changes mattersOptimal 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) |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
$Int16++; $Int32--; ++$Int64; --$Int128 | ||
($Uint16++); ($Uint32--); (++$Uint64); (--$Uint128) }.Ast) | ||
$res.Count | Should -Be 4 | ||
$res.Name -join ',' | Should -Be ('System.UInt16', 'System.UInt32', 'System.UInt64', 'System.UInt128' -join ',') |
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.
Previous tests have one case with string "Hello" and second one with int and we can distinct string and int.
In the tests all is int-s and it is not clear what is line in the test return non-empty result.
I mean we should check (1) first 3 line, (2) then all 4 line.
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 can't use strings because++
and--
only work on numbers. I am differentiating the expected VS unexpected results by using 2 different number types (ints and uints).
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 am differentiating
I was still forced to do a manual check - it is not obvious the tests work correctly.
I suggest making the tests more explicit with two steps:
$res= [AstTypeInference]::InferTypeOf( { [Int16]$Int16=1; [Int32]$Int32=1; [Int64]$Int64=1; [System.Int128]$Int128=1; [UInt16]$Uint16=1; [UInt32]$Uint32=1; [UInt64]$Uint64=1; [System.UInt128]$Uint128=1$Int16++;$Int32--;++$Int64;--$Int128}.Ast)$res.Count| Should-Be0$res= [AstTypeInference]::InferTypeOf( { [Int16]$Int16=1; [Int32]$Int32=1; [Int64]$Int64=1; [System.Int128]$Int128=1; [UInt16]$Uint16=1; [UInt32]$Uint32=1; [UInt64]$Uint64=1; [System.UInt128]$Uint128=1$Int16++;$Int32--;++$Int64;--$Int128 ($Uint16++); ($Uint32--); (++$Uint64); (--$Uint128) }.Ast)$res.Count| Should-Be4$res.Name-join','| Should-Be ('System.UInt16','System.UInt32','System.UInt64','System.UInt128'-join',')
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.
Sure, that makes sense. I've done that now.
57dbde6
intoPowerShell:masterUh oh!
There was an error while loading.Please reload this page.
microsoft-github-policy-servicebot commentedDec 29, 2024 • edited by unfurl-linksbot
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by unfurl-linksbot
Uh oh!
There was an error while loading.Please reload this page.
📣 Hey@MartinGC94, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗https://aka.ms/PSRepoFeedback |
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
Fixes the type inference of statement blocks and named blocks like:
It correctly ignores both assignments and increments/decrements when inferring the output (here is only
$WindowsDir.FullName
) from such blocks.PR Context
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).