You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue manifests whenever a function contains a block (if, foreach, try,...), which writes some output and then calls return. All output from the block is written into the output pipeline, even if the output of the block should be redirected into a variable, or a pipeline inside the function:
function x([switch]$p) {
$null = foreach ($a in @(1)) {
echo "this should not be visible"
if ($p) {return}
}
}
function y([switch]$p) {
$null = try {echo "this should not be visible"; if ($p) {return}} catch {}
}
Expected behavior
PS> xPS> yPS> x -pPS> y -p
Actual behavior
PS> xPS> yPS> x -pthis should not be visiblePS> y -pthis should not be visible
Error details
No response
Environment data
Name Value
---------
PSVersion 7.3.0-preview.6
PSEdition Core
GitCommitId 7.3.0-preview.6
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Prerequisites
Steps to reproduce
The issue manifests whenever a function contains a block (if, foreach, try,...), which writes some output and then calls
return. All output from the block is written into the output pipeline, even if the output of the block should be redirected into a variable, or a pipeline inside the function:Expected behavior
Actual behavior
Error details
No response
Environment data
Visuals
No response