Fix type inference of parameters in classic functions (#25172)

This commit is contained in:
MartinGC94
2025-03-18 13:23:49 +05:00
committed by GitHub
parent 1edd258e3b
commit 0ca17fdacd
2 changed files with 26 additions and 1 deletions
@@ -268,6 +268,16 @@ Describe "Type inference Tests" -tags "CI" {
$res.Name | Should -Be 'System.Management.ManagementObject#root\cimv2\Win32_Process'
}
It "Infers type from parameter in classic function definition" {
$res = [AstTypeInference]::InferTypeOf(({
function MyFunction ([int]$param1)
{
$param1
}
}.Ast.FindAll({param($Ast) $Ast -is [Language.VariableExpressionAst]}, $true) | Select-Object -Last 1 ))
$res.Name | Should -Be 'System.Int32'
}
It "Infers type from binary expression with a bool operator as bool" {
$res = [AstTypeInference]::InferTypeOf( {
(1..10) -contains 5