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

"Cannot read property '0' of undefined" on repeated Vector.appendAll #17

Closed
bwbuchanan opened this issue Sep 6, 2018 · 5 comments
Closed

Comments

@bwbuchanan
Copy link

This code:

import { Vector } from 'prelude.ts';

let v = Vector.ofIterable(Array(15).fill(1));

for (let i = 0; i < 100; i += 1) {
  console.log(i);
  v = v.appendAll(Array(1000).fill(1));
}

Will fail after 86 iterations with:

TypeError: Cannot read property '0' of undefined
    at Vector.getLastNode (node_modules/prelude.ts/src/Vector.ts:279:31)
    at Vector.appendAllArrays (node_modules/prelude.ts/src/Vector.ts:457:34)
    at Vector.appendAll (node_modules/prelude.ts/src/Vector.ts:419:25)
@bwbuchanan
Copy link
Author

Simpler test case:

import { Vector } from 'prelude.ts';

Vector.ofIterable(Array(86015).fill(1)).appendAll([1]);

@bwbuchanan
Copy link
Author

3071 is another magic length that will break appendAll.

Both 3071 and 86015 have the property: N % 32 === 31 && Math.floor(N / 32) % 32 === 31

@emmanueltouzery
Copy link
Owner

Thank you for the report! I'll look into this tonight. You're not really lucky with prelude bugs.. note that I just added a fuzzer test on master exactly to detect such issues.

@bwbuchanan
Copy link
Author

Well, I'm using it in a production system, so that tends to find all the edge cases! :)

@emmanueltouzery
Copy link
Owner

I released 0.7.13 with the fix! Thank you for the patience and the detailed bug reports!

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

No branches or pull requests

2 participants