Skip to content

Fix #770: scheme's #| |# block comments are now actually stripped as nested blocks - #804

Merged
squid-protocol merged 1 commit into
mainfrom
fix/770-scheme-nested-block-comments
Jul 30, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/770-scheme-nested-block-comments

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

  • Closes scheme's #| |# nested block comments are never actually stripped as a block (line_exclusive has no cross-line state) #770. 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 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 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 [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 #|/|# 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.
  • Updated how_to_add_a_language.md's family-examples list (scheme no longer belongs under line_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.json and tests/golden_master_zero_dep_audit.json needed regeneration — this is a real, on-target diff, not noise:

  • scheme/racket files (the intended fix): coding_loc/doc_loc and several structural signature counts shift because previously-leaked commented-out code is now correctly excluded.
  • perl/exiftool.pm (Bitwise Operations: 620→621): a genuine second bug fix. That file's EXE => '...\x7fELF|#!\s*/\S*bin/|...' string literal contains the substring |#, which the old (incorrectly configured) line_exclusive delimiter 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/after Prism.split_streams() diff on this exact file, not just the aggregate report.
  • apex / fortran/wrf (sub-0.1-percentage-point nudges): corpus-wide Z-score/average-exposure normalization (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 fresh pip install -e . --no-deps first). tests/tools/crucible_check.py now passes clean on both.

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 (38/38 pass).
  • Full core_engine/extraction suites 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

…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]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit ed613d7 into main Jul 30, 2026
38 of 39 checks passed
@squid-protocol
squid-protocol deleted the fix/770-scheme-nested-block-comments branch July 30, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scheme's #| |# nested block comments are never actually stripped as a block (line_exclusive has no cross-line state)

1 participant