You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Range operator with char returns unexpected value #5731
# Char array ([char]'a', [char]'b', [char]'c', [char]'d', [char]'e')
a
b
c
d
e
Actual behavior
# Int array (97, 98, 99, 100, 101)979899100101
Environment data
>$PSVersionTable
Name Value
---------
PSVersion 6.0.0-rc.2
PSEdition Core
GitCommitId v6.0.0-rc.2
OS Microsoft Windows 10.0.15063
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Oddly the actual behavior matches Windows PowerShell results. So changing this might break a few scripts that otherwise might work when on PowerShell 6.
I still think it should be modified to give the expected results, but wanted to call out that [char]'a'..[char]'e' did work in previous versions of PowerShell by returning 97-101.
It is bug for PowerShell Core not for Windows PowerShell. Windows PowerShell support only [Int]. PowerShell Core support [char].
It would works with doubles if doubles had an enumerator.
Activity
FireInWinter commentedon Jan 3, 2018
Oddly the actual behavior matches Windows PowerShell results. So changing this might break a few scripts that otherwise might work when on PowerShell 6.
I still think it should be modified to give the expected results, but wanted to call out that
[char]'a'..[char]'e'did work in previous versions of PowerShell by returning 97-101.iSazonov commentedon Jan 4, 2018
FireInWinter Thanks! I'll label the fix as Breaking change.
nightroman commentedon Jan 4, 2018
Is it a bug at all? The operator casts operands to integers and then increments. The result is integers. This looks fine (to me).
What about
1.1 .. 9.1? Should it work with doubles or not?iSazonov commentedon Jan 4, 2018
It is bug for PowerShell Core not for Windows PowerShell. Windows PowerShell support only [Int]. PowerShell Core support [char].
It would works with doubles if doubles had an enumerator.