Repository navigation
Description
Found while starting work on #609 (strict-parsing tests for scheme, part of epic #518).
The bug
scheme is tagged "lexical_family": "line_exclusive", but its own inline comment
(gitgalaxy/standards/language_standards.py ~line 10578-10581) says:
UPGRADED: Maps to Family 9 (Lisp_Semi) - NEW FAMILY
Rationale: Perfectly captures the Lisp ecosystem's reliance on ';' for line-level
comments and#| |#for nested block-level Commented / Non-Executable Text.
The comment describes a genuine nested block-comment family that was apparently intended but
never actually created -- the field was left at the placeholder "line_exclusive" value. Per
how_to_add_a_language.md, line_exclusive is explicitly defined as "The language possesses no
native multi-line block syntax. The engine ignores closing tags" -- the literal opposite of what
scheme's own comment claims about #| |#.
Confirmed empirically via Prism.split_streams() against a realistic multi-line #| ... |#
block comment:
(define (foo x)
#| This is a block comment
spanning multiple lines
(define fake-function x) |#
(+ x 1))code_stream comes back as:
(define (foo x)
spanning multiple lines
(define fake-function x)
(+ x 1))
Only the first line (#| This is a block comment) gets treated as a comment. Every subsequent
line up to (and including) the line containing the closing |# stays in code_stream as if it
were live code -- including the fake (define fake-function x) commented-out function
definition, which would misfire func_start/other structural signatures if a real block comment
happened to contain one.
Root cause
_strip_single_line_comments() (the function line_exclusive dispatches to) is fundamentally
per-line and stateless -- it checks each line independently for a configured delimiter and
truncates from that point to end-of-line. There is no persistent "currently inside an unclosed
block comment" state carried across lines. This is by design for the family's real use cases
(Python's #, Shell's #, etc. have no block form at all), but #|/|# being present in
line_exclusive's shared delimiter list (gitgalaxy_config.py's LEXICAL_FAMILY_HEURISTICS)
implies a nesting/pairing capability the stripper never implements.
Real-world impact
Confirmed in the language-crucible corpus: scheme/racket/io.ss contains 2 real multi-line #| ... |# block comments (implementation-notes prose and an ASCII-art diagram), both several lines
long. Currently, only their opening line is recognized as a comment -- the rest of each block
leaks into code_stream as unstripped prose/diagram text, corrupting doc_loc/coding_loc
accounting for those files and creating a latent false-positive risk for any structural signature
whose pattern could accidentally match commented-out-code text sitting inside one of these blocks
(this specific corpus file's blocks happen to be prose/ASCII-art, not commented-out S-expressions,
so no structural-signature misfire is currently observable there -- but the risk is real for any
scheme file that block-comments out actual code).
Scope
Not fixing this as part of #609 -- matches the epic's established pattern (#691 for markdown,
#694/#697 for yaml/json/csv, #733 for html) of keeping per-language strict-parsing issues
narrowly scoped to the rules-dict regexes, and filing real pipeline-level gaps as their own
issue. #609 will proceed testing the 40 scheme regexes against their actual observed
behavior (raw text matching, not assuming block-comment stripping that doesn't happen).
A real fix likely needs a genuine stateful/paired block-comment stripper (tracking open/close
across lines, similar to _strip_nested_comments's recursive_block handling) wired up for
line_exclusive languages that declare a real block pair (scheme's #|/|#, and this may also
affect other line_exclusive languages sharing those tokens) -- a bigger, dedicated architectural
change, not a one-line delimiter fix like #733's block_exclusive config could have been.
Part of the theme tracked by #386/#691/#694/#697/#733 ("prism.py doesn't correctly honor
per-language/per-family delimiter config") -- same root cause class, new manifestation (a
family whose shared delimiter table lists a block-pair token, but whose actual stripping
implementation has no state-tracking capability to honor it).
Activity
Fix #609: Strict parsing tests for scheme structural signatures (#771)
Fix #770: scheme's #| |# block comments are now actually stripped as …
Fix 3 more flaky timing-based ReDoS regression tests (#806)
ci: dedupe concurrent runs, parallelise pytest, and de-flake the ReDo…