Repository navigation
Fix #770: scheme's #| |# block comments are now actually stripped as nested blocks - #804
Merged
Merged
Conversation
…nested blocks scheme was tagged "line_exclusive" (no cross-line state at all) despite its own inline comment claiming '#| |#' nested block-comment support that was never wired up. Confirmed empirically: only a #| block comment's opening line was ever recognized as a comment -- every subsequent line up to and including the closing |# leaked into code_stream as live code, including any commented-out S-expressions inside it. Fixed by adding a new lexical family, recursive_block_lisp (mirroring recursive_block_haskell from #621): reuses the same iterative inside-out peel algorithm already proven for Rust/Swift/Haskell's genuinely-nestable block comments, just with scheme's own ; / #| / |# tokens. Moved scheme onto this family and removed #|/|# from line_exclusive's shared delimiter list -- scheme was the only language that ever needed them there, and leaving them in a stateless per-line stripper is exactly what caused the bug. Verification: - New test_prism.py coverage: the exact multi-line example from the issue, genuine nesting (#| outer #| inner |# still outer |#), ; line comments still working, string-literal shielding, and a ReDoS-immunity check. - Full core_engine/extraction suites pass; the function/args-extraction scheme test tables were already unaffected (they test regex extraction directly, not comment stripping). - crucible_check.py: real, on-target diff verified before blessing. Dominant cause is scheme/racket's corrected comment/coding_loc counts and structural signatures (the intended fix). Also surfaced a second, genuine bug: perl/exiftool.pm's line_exclusive stripper was truncating a Perl string literal one character early because of a coincidental "|#" substring inside it (`...ELF|#!\s*...`) -- removing #|/|# from line_exclusive's shared delimiter list fixes that collision too (verified via direct before/after Prism.split_streams() diff, not just the aggregate report). The remaining handful of tiny (<0.1 percentage point) ripples in unrelated languages (apex, fortran/wrf) are corpus-wide Z-score/average-exposure normalization (signal_processor.py) shifting a hair because scheme's real signal counts changed -- expected, not a bug. Golden masters (both full-precision and zero-dependency) regenerated via update_golden_master.py; crucible_check.py now passes clean on both. - ruff_audit_baseline.json: 1-line regen for a pure line-shift (PERF401 finding moved from prism.py:512 to :523 due to added comments). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
3 of 4 tasks
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.
Summary
schemewas tagged"line_exclusive"(no cross-line state at all) despite its own inline comment claiming#| |#nested block-comment support that was never wired up. Confirmed empirically via the issue's own example: only a#|block comment's opening line was ever recognized as a comment — every subsequent line up to and including the closing|#leaked intocode_streamas live code, including any commented-out S-expressions inside it.recursive_block_lisp(mirroringrecursive_block_haskellfrom [BUG/CORE-ENGINE] standard_block comment stripping only covers C-style delimiters -- sqlite, lua, haskell, powershell, perl get zero comment/code separation #621): reuses the same iterative inside-out peel algorithm already proven for Rust/Swift/Haskell's genuinely-nestable block comments, just with scheme's own;/#|/|#tokens. Moved scheme onto this family and removed#|/|#fromline_exclusive's shared delimiter list — scheme was the only language that ever needed them there, and leaving them in a stateless per-line stripper is exactly what caused the bug.how_to_add_a_language.md's family-examples list (scheme no longer belongs underline_exclusive); left the historical Rule-12 case-study section as-is since it's still an accurate account of the original finding.Why the golden masters changed
Both
tests/golden_master_audit.jsonandtests/golden_master_zero_dep_audit.jsonneeded regeneration — this is a real, on-target diff, not noise:coding_loc/doc_locand several structural signature counts shift because previously-leaked commented-out code is now correctly excluded.Bitwise Operations: 620→621): a genuine second bug fix. That file'sEXE => '...\x7fELF|#!\s*/\S*bin/|...'string literal contains the substring|#, which the old (incorrectly configured)line_exclusivedelimiter list treated as a real delimiter — matching one character earlier than the file's own real#comment marker would, and truncating a legitimate trailing|(bitwise-or) out of the code stream. Verified via a direct before/afterPrism.split_streams()diff on this exact file, not just the aggregate report.gitgalaxy/metrics/signal_processor.py) shifting a hair because scheme's real signal counts changed elsewhere in the ~80-repo corpus — expected mathematical ripple, not a bug in those files.Regenerated via
tests/tools/update_golden_master.py --yes(both the zero-dep venv and.crucible_venvs/full_precision, each with a freshpip install -e . --no-depsfirst).tests/tools/crucible_check.pynow passes clean on both.Verification
test_prism.pycoverage: the exact multi-line example from the issue, genuine nesting (#| outer #| inner |# still outer |#),;line comments still working, string-literal shielding, and a ReDoS-immunity check (38/38 pass).core_engine/extractionsuites pass (the scheme function/args-extraction test tables were already unaffected — they test regex extraction directly, not comment stripping).ruff format,ruff_audit.py --ci(1-line baseline regen for a pure line-shift),mypy_audit.py --ci,dead_key_audit.py --ci: clean.Test plan
;line-comment and string-shielding regression tests