Skip to content

[SR-187] Incorrect behavior for Int(_, radix:) #42809

Closed
@swift-ci

Description

@swift-ci
Previous ID SR-187
Radar None
Original Reporter PatrickPijnappel (JIRA User)
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, StarterBug
Assignee PatrickPijnappel (JIRA)
Priority Medium

md5: 83c44df492df40d194828ff6d075d8fc

Issue Description:

The docs for Int(_, radix:) lists the regex as being

[-+]?[0-9a-zA-Z]

but the exact regex for the code as is seems to be

(-+?|+?)[0-9a-zA-Z]*|-*0)

That is, it accepts these cases beyond what the docs specify:

  • Any number of minuses followed by a 0

  • A minus followed by a plus followed by any number

It seems unlikely this is by design, and contradicts the documentation by not returning nil in those cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.good first issueGood for newcomersstandard libraryArea: Standard library umbrella

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions