Repository navigation
rdna2spirv.py: check --limit and --shard before translating anything - #591
Merged
ItsNotRexed merged 1 commit intoNov 22, 2026
Merged
Conversation
`files[: a.limit] if a.limit else files` read --limit 0 as "no limit" and translated the whole corpus, and a negative --limit dropped the last shaders instead of being refused. --shard was split and used unchecked: 0/0 ended in "slice step cannot be zero", 9/8 translated nothing and wrote an empty index.part9.json that --merge then reads, and anything that isn't i/n was a traceback. Both are now argparse types: --limit must be at least 1, and --shard must be i/n with n >= 1 and 0 <= i < n. A bad value is a usage error (exit 2) before --out is created. The translation itself is unchanged, and make_game.py's own "--shard i/jobs" values are all valid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IAmNotSiob
approved these changes
Nov 22, 2026
IAmNotSiob
left a comment
Collaborator
There was a problem hiding this comment.
_shard_arg catches 0/0, 3/2, 1 and a/b/c (the unpack raises ValueError), and --limit 0 is now an error instead of quietly meaning the whole corpus. tests/test_rdna2spirv_cli.py passes after merging with main. LGTM. AI-assisted review (Claude Code).
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.
Claim: #374 (comment) (new item, CLI only)
Bug. AGENTS.md tells contributors to check a translator change with
--limit 200and--shard 0/8. Neither value was checked:--limit 0files[: a.limit] if a.limit else filesread 0 as "no limit" and translated the whole corpus, the longest step of the build.--limit -5--shard 0/0ValueError: slice step cannot be zerotraceback.--shard 9/8index.part9.jsoninto--out.--mergethen picks it up.--shard a/b,--shard 0Fix. Two small argparse types:
--limitmust be at least 1.--shardmust bei/nwithn >= 1and0 <= i < n.A bad value is a usage error (exit 2) before
--outis created. The slice test becomesis not None. The translation code is untouched, and every--shard i/{jobs}thatmake_game.pypasses is valid.Tested. New
tests/test_rdna2spirv_cli.py, standard library only, needing nollvm-mcor SPIRV-Tools:--limit 0,--limit -5,--shard 0/0,--shard 9/8and--shard a/b. Each must exit 2 with no traceback and leave no--outfolder. Against main's tool all five CLI cases fail. On main,--shard 9/8exits 0 and writesindex.part9.json.Results:
python -I tests/test_rdna2spirv_cli.py: OK.pytest tests/test_rdna2spirv_cli.py: 3 passed.python -m unittest discover -s tests/semantic: unchanged from main, with the single known failure from spirv_mini_interp: OpBitcast and float outputs quiet signalling-NaN bit patterns (bit 22 flips) #509 that tests/semantic: OpBitcast keeps signalling-NaN bits in the mini interpreter (TEST-67) #533 fixes.spirv-valcounts are unaffected. I didn't run the corpus because the translation paths are untouched.AI-assisted (Claude Code).
Checklist
🤖 Generated with Claude Code