-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Resolution-Won't FixThe issue won't be fixed, possibly due to compatibility reason.The issue won't be fixed, possibly due to compatibility reason.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
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:
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> x
PS> y
PS> x -p
PS> y -pActual behavior
PS> x
PS> y
PS> x -p
this should not be visible
PS> y -p
this should not be visibleError 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.0Visuals
No response
Metadata
Metadata
Assignees
Labels
Resolution-Won't FixThe issue won't be fixed, possibly due to compatibility reason.The issue won't be fixed, possibly due to compatibility reason.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation