semantic_mutants: leave docstrings alone, so their op names are not reported as surviving mutants (OLD-9432) #660
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!660
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/660/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@qhukz13 on GitHub · 2026-11-24 11:13 UTC · original
qhukz13:cont/semantic-mutants-docstrings→main· +138 −0 · 2 files · 3 commits · merged 2026-11-24 16:06 UTCClaimed in the coordination issue as: OLD-9432 (restoration of ItsNotRexed/Leonida#9432, closed unmerged when that repository went private)
mutants_fortreated any line starting with a quote as code (meant forf"... OpIAdd ..."emit lines), so a docstring naming an opcode produced mutants that can never fail a test and were always reported SURVIVED:--function nminmax_f32listed 5 mutants, 4 of them in its docstring, and 47 acrossrdna2spirv.py.--linesrange that starts inside a docstring is widened to the whole string (from review on the original PR:--lines 595-595insideu16_half's docstring was mutated as code). Every one of the translator's 1,049 docstring lines now gives 0 mutants as a one-line range.Tested:
python -I tests/test_semantic_mutants.py(13 tests OK) onmain21625bca8, Linux, CPU only; no GPU needed. No game files.AI-assisted (Claude Code).
🤖 Generated with Claude Code
@lixonik on GitHub · 2026-11-24 11:53 UTC · original · reviewed
Independent CLI check at
e3c4d0c1with synthetic Python sources and--lines N-N --list. A one-line range inside an ordinary multiline docstring yields zero mutants. Adding a preceding comment containing"""makes the equivalent range yield one mutant,OpIAddtoOpISub. An implicitly concatenated first-statement docstring also yields one mutant:"OpIAdd is an example. " "Emit an instruction.".Python's
ast.get_docstring()recognizes both variants. The first appears to come from counting delimiters in raw lines and the second from treating adjacent string tokens as separate statements. A scan of the checked-in translator's docstrings found zero mutants, so these are synthetic coverage cases. Could both be added to the regression tests? Relevant logicAI-assisted testing. No game data or GPU used.
@GeorgiyDemo on GitHub · 2026-11-24 13:03 UTC · original
Ran
e3c4d0c1fon Apple M5 Pro, macOS 26.7.3 (25G342), Python 3.15.2, againstmaind42773d07:tests/test_semantic_mutants.py: 13 tests OK at this head.main'stools/semantic_mutants.pyfails 5 of 13, so the docstring handling is covered by the new cases.No GPU leg (CPU tool). AI-assisted.
@qhukz13 on GitHub · 2026-11-24 13:13 UTC · original
Thanks — both reproduced and fixed in 4a5458b05:
"""in a comment no longer counts as a delimiter:string_contextnow follows triple quotes with a small scanner that skips comments, one-line strings and escaped delimiters, instead of counting them in raw lines.docstring_linestakes a run of string tokens that ends the statement ("OpIAdd is an example. " "Emit an instruction."). A literal the code goes on to read (("..." "...") and self.emit(...)) stays code and is still mutated.Both cases are in
test_docstring_after_a_comment_with_quotes_and_concatenated_docstring, plus the stays-code one; it fails on e3c4d0c1f and passes now.tests/test_semantic_mutants.py: 14 tests OK. #734, which builds on this branch, is rebased on it (20 tests OK).@lixonik on GitHub · 2026-11-24 13:35 UTC · original
Thanks for the fix. I independently retested
4a5458b05from a full Git checkout on Windows. The new regression test covering the quote-in-comment case, the concatenated docstring, and the expression that should remain mutable passes. The fullpython -I -B tests/test_semantic_mutants.py -vrun passed all 14 tests.AI-assisted testing with synthetic inputs. No game data or GPU used.