Skip to content
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

Fix variable type inference precedence #18691

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into FixVarTypeInferencePrecedence
  • Loading branch information
MartinGC94 committed Jan 18, 2023
commit 6ba92b51a1ae7008b5b21e06f37c7e3a1d5f14ad
17 changes: 17 additions & 0 deletions test/powershell/engine/Api/TypeInference.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,23 @@ Describe "Type inference Tests" -tags "CI" {
($Object.Property1 = 2) }.Ast)
$res.Name | Should -Be "System.String"
}

It 'Infers type of $null after variable assignment' {
$res = [AstTypeInference]::InferTypeOf( { $null = "Hello";$null }.Ast)
$res.Count | Should -Be 0
}

It 'Infers type of all scope variable after variable assignment' {
$res = [AstTypeInference]::InferTypeOf( { $true = "Hello";$true }.Ast)
$res.Count | Should -Be 1
$res.Name | Should -Be 'System.Boolean'
}

It 'Infers type of all scope variable host after variable assignment' {
$res = [AstTypeInference]::InferTypeOf( { $Host = "Hello";$Host }.Ast, [TypeInferenceRuntimePermissions]::AllowSafeEval)
$res.Count | Should -Be 1
$res.Name | Should -Be 'System.Management.Automation.Internal.Host.InternalHost'
}
}

Describe "AstTypeInference tests" -Tags CI {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.