Reputation: 30235
The following script gives different results when it is run on 5.1 compared to 7.4.0.
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:
Is this a bug in PS Core (it's certainly unexpected to me) or is this a documented change/was always undefined behavior?
Upvotes: 6
Views: 119