-
Notifications
You must be signed in to change notification settings - Fork 51
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
Possible accidental mutation #36
Comments
Hmm, that does look like a bug, especially the magic length of 32. Let me
take a look.
…On Mon, Jul 12, 2021 at 10:15 AM, GTRI-nathan ***@***.***> wrote:
Hi, first off, very cool library & benchmarks!
I'm not sure if I'm doing something wrong or making an incorrect
assumption, but I think I've found a bug causing accidental mutation in
List in 0.2.0-alpha6, see my minifed reproducer:
import io.lacuna.bifurcan.List;
public class Test {
public static void main(String args[]) {
int size = 32;
List<Integer> a = new List<Integer>();
List<Integer> b = new List<Integer>();
for (int i = 0; i < size; i++) {
a = a.addLast(1);
b = b.addLast(1);
}
List<Integer> ap = a.set(15, 2);
List<Integer> bp = b.set(15, 2);
List<Integer> z = null;
// Comment out, and the equals is true
z = ap.set(15, 3);
System.out.println("a: " + a);
System.out.println("b: " + b);
System.out.println("ap:" + ap);
System.out.println("bp:" + bp);
System.out.println("z: " + z);
System.out.println("Should be true: " + ap.equals(bp));
}
}
Will print:
~/test ➜ javac -cp "./bifurcan-0.2.0-alpha6.jar" Test.java <http://test.java/> && java -cp ".:./bifurcan-0.2.0-alpha6.jar" Test
a: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
b: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
ap:[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
bp:[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
z: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
Should be true: false
Commenting out the z = ap.set(15,3); line, or changing the size to
anything less than 32 will make the result true.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#36>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAHUP746AYEFUAQWYTN5S3TXMPLHANCNFSM5AHIKWNQ>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, first off, very cool library & benchmarks!
I'm not sure if I'm doing something wrong or making an incorrect assumption, but I think I've found a bug causing accidental mutation in List in 0.2.0-alpha6, see my minifed reproducer:
Will print:
Commenting out the
z = ap.set(15,3);
line, or changing the size to anything less than 32 will make the result true.The text was updated successfully, but these errors were encountered: