Skip to content

Range operator with char returns unexpected value #5731

Description

Steps to reproduce

[char]'a'..[char]'e'

Expected behavior

# 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)
97
98
99
100
101

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

Activity

  1. FireInWinter commented on Jan 3, 2018

    @FireInWinter

    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.

  2. iSazonov commented on Jan 4, 2018

    @iSazonov
    Collaborator

    FireInWinter Thanks! I'll label the fix as Breaking change.

  3. nightroman commented on Jan 4, 2018

    @nightroman

    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?

  4. iSazonov commented on Jan 4, 2018

    @iSazonov
    Collaborator

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Breaking-Changebreaking change that may affect usersIssue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Languageparser, language semantics

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions