Repository navigation
Commit 06129ad
fix: uneval grows sparse arrays by one slot when first hole is past index 0 (#160)
* fix: do not grow sparse arrays by one slot in uneval
When the first hole in an array literal was at an index greater than 0,
uneval emitted two commas for it: one from `if (i > 0) result += ','` at
the top of the iteration, and a second after `i -= 1` re-processed the
same index. So `uneval([1, , 3])` produced `[1,,,3]` (length 4) instead
of `[1,,3]` (length 3), and the round-tripped array gained a slot.
The comma at the top of the iteration already represents the hole, so
drop the `i -= 1` re-processing.
* chore: add changeset
* Apply suggestion from @elliott-with-the-longest-name-on-github
---------
Co-authored-by: Elliott Johnson <hello+github@ell.iott.dev>1 parent 756265a commit 06129ad
3 files changed
Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
265 | 264 | | |
266 | | - | |
267 | 265 | | |
268 | 266 | | |
269 | 267 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1422 | 1422 | | |
1423 | 1423 | | |
1424 | 1424 | | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
1425 | 1436 | | |
1426 | 1437 | | |
1427 | 1438 | | |
| |||
0 commit comments