mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix type inference of parameters in classic functions (#25172)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user