Skip to content

Pipeline stops enumerating on encountering a second AutomationNull value in the input #14920

@mklement0

Description

@mklement0

Steps to reproduce

Note: (& {}) is used to produce AutomationNull, i.e. the [System.Management.Automation.Internal.AutomationNull]::Value singleton representing "no output" in PowerShell.

$automationNull = & {}
1, $automationNull, 2, $automationNull, 3, 4, 5 | ForEach-Object { $_ }  | Should -Be (1..5)

Expected behavior

The test should pass: all non-AutomationNull values should be passed through (while the AutomationNull values in the input are apparently themselves not sent through the pipeline).

Actual behavior

The test fails, because enumeration unexpectedly stops on encountering the second non-AutomationNull value.

Expected @(1, 2, 3, 4, 5), but got @(1, 2).

Note that using true $null values does not exhibit the problem: the following test succeeds:

1, $null, 2, $null, 3, 4, 5 | ForEach-Object { $_ }  | Should -Be 1, $null, 2, $null, 3, 4, 5 # OK

Environment data

PowerShell Core 7.2.0-preview.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions