Skip to content

slice pattern bug #24875

Closed
Closed
@mind-zz

Description

@mind-zz

The following program prints 102. Commenting out the match arm for either 100 or 102 causes the correct value (101) to be printed. I believe the first and third cases are being merged as they have the same form (but different guards), ruining the priority.

#![feature(slice_patterns)]

fn main() {
    let v = vec![1, 2];
    println!("{}", test(&v));
}

fn test(a: &[u64]) -> u64 {
    match a {
        [a, b ..]  if a == 3  => 100,
        [a, b]     if a == 1  => 101,
        [a, b ..]             => 102,
        _                     => 103
    }
}
// rustc 1.1.0-dev (69e47c77b 2015-04-23) (built 2015-04-23)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions