Repository navigation
Description
Found while writing strict parsing tests for abap (#571, part of epic #518). Same
category of finding as #733/#735: a real gap in prism.py's comment/code stream
separation, not a bug in language_standards.py's abap rules dict.
The gap
Prism._strip_positional_comments() (the function positional_anchored languages are
routed to) only recognizes:
- Column-1 or column-7
*/C/c///!(POSITIONAL_ANCHORS) for full-line comments - Inline
*>(modern COBOL) or!(Fortran) as trailing-comment splitters
ABAP's real, and by far most common, inline-comment convention is a bare " (double
quote) starting anywhere on a line. That character is not in POSITIONAL_ANCHORS and
not handled by the inline-split branches at all, so a line like:
DATA lv_foo TYPE i. " old logic: DATA lv_bar TYPE i.never gets split -- the entire line, including the text after ", stays in the code
stream. The isolated comment stream that detector.py's comment_analysis() scans
for dead_code/doc/ownership/etc. never sees it.
Confirmed end-to-end with the real Prism class (not just the isolated regex):
from gitgalaxy.core.prism import Prism
from gitgalaxy.standards.language_standards import LANGUAGE_DEFINITIONS
from gitgalaxy.standards.gitgalaxy_config import LEXICAL_FAMILY_HEURISTICS
p = Prism(LEXICAL_FAMILY_HEURISTICS, LANGUAGE_DEFINITIONS)
src = 'DATA lv_foo TYPE i. " old logic: DATA lv_bar TYPE i.\n"! @parameter iv_x | The input\n'
code, comment = p._strip_segment_comments(src, "abap", "positional_anchored")
# code == 'DATA lv_foo TYPE i. " old logic: DATA lv_bar TYPE i.\n"\n' (everything, unsplit)
# comment == '! @parameter iv_x | The input' (leading '"' lost too)Two concrete consequences in abap's rules dict (both regexes are individually correct
and pass unit-level regex tests -- this is purely an integration gap):
dead_code's"[ \t]*(?:DATA|METHOD|IF|SELECT|WRITE)\balternative can never fire --
the commented-out code it's meant to catch never reaches the comment stream.doc's^"!\s*@(?:parameter|raising|return)(ABAPDoc) alternative can never fire
either way: not only does the line not get routed to the comment stream, but even
when a line does contain a bare!elsewhere (tripping the generic Fortran-style
inline-!branch), the split point is wrong -- the leading"lands in the code
stream and only!...survives into the comment stream, so the regex's required
leading"is missing from what it actually sees.
Why this isn't fixed inline in #571
This lives in shared prism.py code, not abap's own rules dict, and affects the
positional_anchored family used by 3 languages (COBOL, Fortran, ABAP). Fortran and
COBOL's own dead_code/doc/ownership rules were checked and rely only on
!/*>/column-anchored */C/c -- all of which are handled correctly today, so
they're unaffected. A blind fix (adding bare " as a family-wide inline delimiter) would
be dangerous: Fortran character literals can legitimately use double-quoted strings
("Hello"), so treating " as a universal positional-family comment starter risks
misclassifying real Fortran string literals as comments. This needs either an
ABAP-specific carve-out (in tension with the recent, deliberate move away from
per-language comment-delimiter config -- see the note about the removed
_line_anchor/_inline_comment/_block_start/_block_end keys) or a proper design
decision, not a reflexive patch buried in a test-coverage PR.
Suggested next step
Decide how positional_anchored should express a language-specific inline marker
(ABAP's ") without reopening the old per-language delimiter-key design, then fix
Prism._strip_positional_comments() and add coverage in tests/core_engine/test_prism.py
(which already constructs a real Prism(LEXICAL_FAMILY_HEURISTICS, LANGUAGE_DEFINITIONS)
for this kind of test). Re-verify against golden_crucible since any abap corpus file
using " comments will shift dead_code/doc counts once fixed.
Part of #518.
Activity
Fix #571: Strict parsing tests for abap structural signatures (#750)
fix(abap): Support inline double-quote comments (Issue #746) (#756)