Skip to content

Vector::new_with_bits accepts values that make the very first push_back panic #112

Description

@DRMacIver
fn main() {
    let v: rpds::Vector<i32> = rpds::Vector::new_with_bits(64);
    let v = v.push_back(0);
    println!("{:?}", v.get(0));
}
thread 'main' panicked at src/vector/mod.rs:387:9:
attempt to shift left with overflow

new_with_bits only requires bits > 0, so 64 is accepted and construction succeeds; the first push_back then panics in debug (in release it does not panic). Either new_with_bits should reject a bits value it can't support, or the resulting Vector should be usable — not accept it and then panic on the first push.

Tested on rpds 1.2.1.

BTW, this bug was found using hegel. Happy to contribute the tests if you're interested.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions