-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
7.4-regressionRegression in 7.4Regression in 7.4In-PRIndicates that a PR is out for the issueIndicates that a PR is out for the issueNeeds-InvestigationThe behavior reported in the issue is unexpected and needs further investigation.The behavior reported in the issue is unexpected and needs further investigation.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group
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
Executing the following script in PowerShell 7.4.0 results in an unexpected behavior which also differs from PowerShell 5.1
function foo($x) {
$val = switch ($x){
1 { 5 }
default {
return 10
}
}
Write-Host "Val is $val"
$val + 1
}
Write-Host "foo 1: $(foo 1)"
Write-Host "foo 2: $(foo 2)"
PS 5.1 output:
Val is 5
foo 1: 6
foo 2: 10
PS 7.4.0 output:
Val is 5
foo 1: 6
foo 2:
It's not clear if this is a bug or simply a documente change from classic PowerShell, but it certainly behaves in a way I don't find intuitive.
Expected behavior
PS> <execute script>
Val is 5
foo 1: 6
foo 2: 10Actual behavior
PS> <execute script>
Val is 5
foo 1: 6
foo 2:Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name Value
---- -----
PSVersion 5.1.19041.3570
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.3570
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1Visuals
No response
mklement0
Metadata
Metadata
Assignees
Labels
7.4-regressionRegression in 7.4Regression in 7.4In-PRIndicates that a PR is out for the issueIndicates that a PR is out for the issueNeeds-InvestigationThe behavior reported in the issue is unexpected and needs further investigation.The behavior reported in the issue is unexpected and needs further investigation.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group