-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productWG-Languageparser, language semanticsparser, language semantics
Description
Steps to reproduce
[bool]0n
[bigint]'1n'Expected behavior
As BigInteger is a number, for all common intents and purposes, a 0 value should cast to $false just like other numbers.
Also, casting from a string to a biginteger should work with a numeric type suffix just like [long]'100L' does.
False
1 # of type System.Numerics.BigInteger
Actual behavior
True
InvalidArgument: Cannot convert value "1n" to type "System.Numerics.BigInteger". Error: "The value could not be parsed."
The behaviour in terms of casting to bool is standard for structs, which always cast to $true. In the case of BigInteger, however, it is simply a slightly more complicated basic value type in function, so it's more appropriate to cast it to $false is the value is 0.
However, casting from an otherwise parseable string should always work for BigInteger; the engine recognises 1n as a biginteger literal -- there's no reason it should fail to see it when casting from a string value as other suffixes work just fine.
Environment data
Name Value
---- -----
PSVersion 7.1.0-preview.2
PSEdition Core
GitCommitId 7.1.0-preview.2
OS Darwin 19.3.0 Darwin Kernel Version 19.3.0: Thu Jan 9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
mklement0, gurnec and IISResetMe
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productWG-Languageparser, language semanticsparser, language semantics