fix: accept * N anywhere in the track header, not only the first slot - #6
Merged
Conversation
`* N` was recognized only immediately after `gen <id>`. Anywhere else it fell through to the key/value loop and became a macro param literally named `*`, so track Pad id pad gen gameBoyDmg layer 0 * 16 silently lost its pattern length and played as ONE bar. No error — the length just became the default. Emit always writes `* N` first, which is why this survived: it only bites hand-written and generated files. tish-gba has 24 such track lines across 4 songs, and two of them bake differently because of it — found by diffing the baked ROM data before and after moving that repo onto this parser. Now `* N` and the trailing `key value` pairs are accepted in any order, and a `*` that names no valid length is an error rather than a dropped token — a length that quietly becomes 1 is the worst kind of wrong. Corpus case 002 gains both orderings; coverage holds at 100%.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
* Nwas recognized only in the slot immediately aftergen <id>. Anywhere else it fell through to the key/value loop and became a macro param literally named*:→
loopBars: null,genParams: { layer: 0, "*": 16 }The pattern length silently became 1 bar instead of 16. No error, no warning — just a song playing at 1/16th of its intended length.
How it was found
Moving tish-gba onto this parser (it had its own hand-written one that scanned header tokens in any order). I diffed the baked ROM data for all 77 shipped
.deckfiles, old parser vs new — 75 were byte-identical and 2 were not. Both were this.It's not rare in that corpus:
This survived because
emitalways writes* Nfirst — so round-tripping through a host never reproduces it. It only bites hand-written and generated files, which is most of tish-gba's corpus.Fix
* Nand the trailingkey valuepairs are now accepted in any order aftergen <id>. And a*that names no valid length (* 0,* zz, a bare trailing*) is an error rather than a quietly dropped token — a pattern length that silently becomes 1 is the worst kind of wrong.Verification
Corpus case
002-track-headergains both non-canonical orderings, so the expected-parse file now pins this. Suite green, coverage back at 100% lines/functions/statements (54/54).Once this releases and
deckfilerepublishes, tish-gba's 77-song bake becomes byte-identical to its old hand-written parser — which is the acceptance test for retiring that parser entirely.