Assignment of $NULL to a BOOL variable does not work
See original GitHub issuePrerequisites
- 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
[BOOL] $X = $NULL
Expected behavior
-NOT $X
Actual behavior
MetadataError
Error details
Cannot convert value "" to type "System.Boolean". Boolean parameters accept only Boolean values and numbers, such as $True, $False, 1 or 0.
Environment data
System.Management.Automation.PSVersionHashTable
Visuals
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
A value of type 'bool?' can't be assigned to a variable of ...
1 Answer. You are getting that error because the getter isDialogOpen returns an Optional. This means the return value can either be a...
Read more >Can bool variable be NULL
In C++, null is defined as "an integer literal with value zero". So, if you were to assign null to a bool ,...
Read more >Nullable value types - C# reference
As a value type is implicitly convertible to the corresponding nullable value type, you can assign a value to a variable of a...
Read more >Booleans - Manual
The bool type only has two values, and is used to express a truth value. ... which won't work in JavaScript where you...
Read more >Avoid Null Booleans in Java. Do you prefer boxed primitives?
A null Boolean means that the variable has no reference assigned, so it is neither true nor false, it is “nothing”.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No. In pwsh 7.1.5 and in powershell 5.1 there are not any errors:
No, this is not a regression. It’s the same behavior on PowerShell 7.1.x and even Windows PowerShell 5.1