Fix parsing for array literals in index expressions in method calls (#19224)

This commit is contained in:
MartinGC94
2023-06-05 14:10:03 -07:00
committed by GitHub
parent ddd150dc24
commit 6520c05949
2 changed files with 21 additions and 1 deletions
@@ -665,6 +665,15 @@ Describe "Parsing using statement with alias and linebreak and comma" -Tag CI {
}
}
It "Should correctly parse array literals for index expressions in method calls" {
$tks = $null
$ers = $null
$Script = '[string]::join(" ", (0, 1, 2)[0, 1])'
$result = [System.Management.Automation.Language.Parser]::ParseInput($Script, [ref]$tks, [ref]$ers)
$result.EndBlock.Statements[0].PipelineElements[0].Expression.Arguments[1].Index.Elements.Count | Should -Be 2
$ers.Count | Should -Be 0
}
It "Should correctly parse array types that are used as arguments without brackets in generic type" {
$tks = $null
$ers = $null