Skip to content

".".parse() returns Ok(0.0) #30344

Closed
@hanna-kruppe

Description

@hanna-kruppe

This program prints Ok(0) where I would expect an Err(..):

fn main() {
    println!("{:?}", ".".parse::<f64>());
}

If I remember correctly, this behavior has been around since pre-1.0 but it would be good if someone who has multirust available could verify that (at least for 1.0 final if earlier builds are harder to get).

Unfortunately even if we all agree that this behavior is wrong, it may not be worth the potential breakage to fix. For example, recent changes to the integer FromStr format (allowing leading plus) did, surprisingly, break real code. It's quite possible that fixing this wart is not worth the risk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.P-mediumMedium priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions