Commit 871d21b
The ABAP lexer crashed on the way nearly every ABAP file begins
*&---------------------------------------------------------------------*
*& Report Z_SOMETHING
*&---------------------------------------------------------------------*
REPORT z_something.
`_scan_line` returned early on a column-1 `*` comment — before the line that
recorded whether the line had left a literal open. The splitter reads that record
on the very next statement, off the function object.
So the FIRST file scanned in a process whose first line is a comment raised
AttributeError. scan_tree does not catch it, so one ordinary abapGit banner
failed the whole abap_sast module and the run reported no custom-code findings at
all. I found it by writing a fixture that opens with a comment, which no existing
fixture does — all nine start on a keyword.
The second defect is quieter and was the reason to fix this properly rather than
set the attribute on one more path. Once any non-comment line had set it, the
value persisted ON THE FUNCTION across comment lines and across FILES. A file
ending inside an open literal left it True, and the next file to begin with a
comment had its first statement marked `degraded` — a lexer fault attributed to
an innocent file, and one more on the `lex_degraded` count that raises a coverage
finding about mis-lexed objects.
`_scan_line` now returns the fact as its fifth value, so a path that forgets to
produce it cannot compile rather than reading a stale one, and the attribute is
gone. The comment defending the original design cited "four call sites [that]
depend on" the signature; there were two.
A comment line returns False rather than recomputing from the carried stack —
they are equivalent on every stack the comment guard can be reached with, and
False says the thing that is true: a comment opens nothing and closes nothing.
Three of the four mutations run against the new test fail it; the fourth was
provably a no-op rewrite of the same constant, not an escaped defect.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 8c462dc commit 871d21b
2 files changed
Lines changed: 140 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
572 | 572 | | |
573 | 573 | | |
574 | 574 | | |
575 | | - | |
576 | | - | |
| 575 | + | |
| 576 | + | |
577 | 577 | | |
578 | 578 | | |
579 | 579 | | |
| |||
934 | 934 | | |
935 | 935 | | |
936 | 936 | | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
937 | 941 | | |
938 | | - | |
| 942 | + | |
939 | 943 | | |
940 | 944 | | |
941 | 945 | | |
| |||
1071 | 1075 | | |
1072 | 1076 | | |
1073 | 1077 | | |
1074 | | - | |
1075 | | - | |
1076 | | - | |
1077 | | - | |
| 1078 | + | |
| 1079 | + | |
1078 | 1080 | | |
1079 | 1081 | | |
1080 | 1082 | | |
| |||
1744 | 1746 | | |
1745 | 1747 | | |
1746 | 1748 | | |
1747 | | - | |
| 1749 | + | |
1748 | 1750 | | |
1749 | 1751 | | |
1750 | 1752 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
0 commit comments