Skip to content

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

Closed

Description

@squid-protocol

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

  1. added
    bug
    core-engine
    on Jul 30, 2026
  2. added a commit that references this issue on Jul 30, 2026
  3. added 2 commits that reference this issue on Jul 30, 2026
    ed613d7
    78bd26a
  4. added this to the v2.4.6 milestone on Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions