Fix infinite loop in variable type inference (#25206)

This commit is contained in:
MartinGC94
2025-03-26 07:53:08 +05:00
committed by GitHub
parent e4dc2ad998
commit dea739cf99
2 changed files with 9 additions and 1 deletions
@@ -1197,6 +1197,12 @@ Describe "Type inference Tests" -tags "CI" {
$res.Name | Should -Be System.String
}
It 'Ignores the last assignment when a variable is reused' {
$variableAst = { $x = New-Guid; $x = $x.Where{$_} }.Ast.FindAll({ param($a) $a -is [Language.VariableExpressionAst] }, $true) | select -Last 1
$res = [AstTypeInference]::InferTypeOf($variableAst)
$res.Name | Should -Be System.Guid
}
$catchClauseTypes = @(
@{ Type = 'System.ArgumentException' }
@{ Type = 'System.ArgumentNullException' }