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

Additional Vector::ptr_eq confusions #131

Closed
cmyr opened this issue May 13, 2020 · 1 comment · Fixed by #132
Closed

Additional Vector::ptr_eq confusions #131

cmyr opened this issue May 13, 2020 · 1 comment · Fixed by #132

Comments

@cmyr
Copy link
Contributor

cmyr commented May 13, 2020

Trying to understand what behaviour I should expect from Vector::ptr_eq.

In particular, I am surprised that the following test passes:

#[test]
fn ptr_eq_huh() {
    let smol = std::iter::repeat(42).take(64).collect::<Vector<_>>();
    let mut smol2 = smol.clone();
    assert!(smol.ptr_eq(&smol2));
    smol2.set(63, 420);
    assert!(!smol.ptr_eq(&smol2));

    let huge = std::iter::repeat(42).take(65).collect::<Vector<_>>();
    let mut huge2 = huge.clone();
    assert!(huge.ptr_eq(&huge2));
    huge2.set(63, 420);
    assert!(huge.ptr_eq(&huge2));
}

That is: with 64 elements the ptr_eq returns false after mutation, and with 65 elements (and any more than that, as far as I've tested) it returns true.

I assume this is just a bug, but nothing has jumped out at me. I'll look at this a bit more, but curious for any guidance.

cmyr added a commit to cmyr/im-rs that referenced this issue May 13, 2020
I believe the intent of this code was to consider the last two
operations as a single OR. (I may be wrong)

- closes bodil#131
@cmyr
Copy link
Contributor Author

cmyr commented May 13, 2020

Ok, I have a maybe-solution up at #132? 🤷

cmyr added a commit to cmyr/im-rs that referenced this issue May 13, 2020
~I believe the intent of this code was to consider the last two
operations as a single OR. (I may be wrong)~

update: It looks like this is a bug, introduced into the PartialEq
impl in 6d0b068, and then copied over when ptr_eq was added.

- closes bodil#131
cmyr added a commit to cmyr/im-rs that referenced this issue May 13, 2020
~I believe the intent of this code was to consider the last two
operations as a single OR. (I may be wrong)~

update: It looks like this is a bug, introduced into the PartialEq
impl in 6d0b068, and then copied over when ptr_eq was added.

- closes bodil#131
bodil pushed a commit that referenced this issue May 15, 2020
~I believe the intent of this code was to consider the last two
operations as a single OR. (I may be wrong)~

update: It looks like this is a bug, introduced into the PartialEq
impl in 6d0b068, and then copied over when ptr_eq was added.

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

Successfully merging a pull request may close this issue.

1 participant