New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default case in Switch not called when variable is in an undefined state #21558
Comments
In an enumeration context - including input provided to a That is, it behaves like the following statement: What is tricky is that it isn't easy to discover whether a given variable value is a bona fide #13465 is a green-lit proposal to make discovery of |
|
@237dmitry
Produces no output when the default case should have been run. |
Thanks @mklement0 for the detailed explaination. Any plans to reopen the conversation of your proposed implementation? |
This is because there is a $null switch, which is equivalent to $Test and returns $true. If you have a match, then Look at full syntax: $ & {
$test = $null
switch ($test)
{
{$_ -eq 1} { 1 }
{$_ -eq 'one'} { 'one' }
{$_ -eq $null} { 'null' }
default { 'default' }
}
}
null
$ |
Glad to hear it helped, @TheToor; I have no say in what gets reopened, but I generally think that all auto-closed issues that have the |
Prerequisites
Steps to reproduce
The following code gives no output:
The following codes gives an output on the $null case:
Expected behavior
Either the $null or Default case should be called
Actual behavior
Error details
No error
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: