Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting prerelease versions doesn't work #73

Closed
steveklabnik opened this issue Feb 1, 2016 · 7 comments
Closed

Selecting prerelease versions doesn't work #73

steveklabnik opened this issue Feb 1, 2016 · 7 comments
Labels

Comments

@steveklabnik
Copy link
Contributor

This test fails:

    #[test]
    pub fn test_pre() {
        let r = req("2.1.1-really.0");
        assert_match(&r, &["2.1.1-really.0"]);
    }

Discovered in rust-lang/cargo#2337

@steveklabnik
Copy link
Contributor Author

Here's the core of it:

[AlphaNumeric("really"), AlphaNumeric("0")] == [AlphaNumeric("really"), Numeric(0)]

these are not considered equal for some reason

@steveklabnik
Copy link
Contributor Author

So the root of the issue is multiple pre sections. With just -really, this works.

@steveklabnik
Copy link
Contributor Author

Hrm, so https://play.rust-lang.org/?gist=f399089d777f3fc4effd&version=stable

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum Identifier {
    /// An identifier that's solely numbers.
    Numeric(u64),
    /// An identifier with letters and numbers.
    AlphaNumeric(String)
}

I am confused as to how these two differ. We only use derive for {Partial,}Eq, so...

@steveklabnik
Copy link
Contributor Author

Using the same definitions also works: https://play.rust-lang.org/?gist=cffbc41f771a38132c79&version=stable

ugh.

@steveklabnik
Copy link
Contributor Author

OH: AlphaNumeric("0") vs Numeric(0)

Somehow, these two versions are being parsed differently. That's the problem.

@steveklabnik
Copy link
Contributor Author

Adjusting the test:

        let v1 = VersionReq::parse("2.1.1-really.0").unwrap();
        let v2 = Version::parse("2.1.1-really.0").unwrap();
        println!("v1: {:?}", v1);
        println!("v2: {:?}", v2);

gives

v1: VersionReq { predicates: [Predicate { op: Compatible, major: 2, minor: Some(1), patch: Some(1), pre: [AlphaNumeric("really"), AlphaNumeric("0")] }] }
v2: Version { major: 2, minor: 1, patch: 1, pre: [AlphaNumeric("really"), Numeric(0)], build: [] }

So, it's that VersionReq parsing has a bug: it thinks that 0 is an AlphaNumeric when it should be a Numeric.

If only I had done that nom port already, I bet this wouldn't have happened :(

steveklabnik added a commit that referenced this issue Feb 1, 2016
With this extra conditional, a pre-release version of 0 gets parsed as an
AlphaNumeric rather than a Numeric.

Fixes #73
@steveklabnik
Copy link
Contributor Author

PR submitted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant