Repository navigation
fix(include,omit): a terminator in a comment closes a COMPILE/OMIT block - #860
Conversation
Both scans stripped every quoted string from a line before looking for
the terminator, the comment included, so the marker idiom !'*Debug*'
never closed its block, and neither looked at the rest of the
directive's own line (COMPILE('*X*',_X_); F() !'*X*'). With the switch
off the block ran to the end of the file: every later INCLUDE counted
as not compiled and the missing-include check flagged their classes.
A comment is now plain text; a terminator in a string in code still
does not close. The detector also stops reading a trailing comment as
a condition argument. New ConditionalCompileTerminatorInComment tests:
6 fail without the fix; suite 4562 passing, 0 failing, 3 pending.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. The code does what it says: the build is clean, 6 of the 11 tests fail on the base, the suite passes, and it merges cleanly with head. The comment scanning ( The one problem is the rule for a terminator inside a string in code. The help only says the block ends with "the line that contains" the terminator, so I compiled each case on Clarion 10. Each case was its own project, and the code inside the block refers to an unknown identifier, so the errors show which lines were compiled:
So the compiler does a plain text match on the line, whether the terminator is in a comment, in a string or inside a word. The two "a terminator in a string in code does not close" guard tests assert the opposite. As the PR stands, the extension would treat the rest of the block as omitted after Could you change — Alice |
…ipped or compiled Review follow-up. Probing Clarion 11.1 and 12 shows two rules, depending on whether the compiler skips the block or compiles it: - skipped (OMIT, COMPILE with a false condition): a plain text search, so the terminator closes the block anywhere on the line, inside a string or inside a word too; - compiled (COMPILE, OMIT with a false condition): the compiler reads through string literals, so a terminator inside a string does not close the block; one in code or in a comment does. The match is case-sensitive either way. terminatorOnLine takes the block's state: scanConditionalCompile passes whether the block omits (an undecided block is read as compiled), OmitCompileDetector whether it is an OMIT (it tracks only unconditional blocks). Tests: 8 new in ConditionalCompileTerminatorInComment.test.ts; 4 fail on the previous rule and 3 on a plain search everywhere. Four existing tests asserted that a string never closes an OMIT: the 807 one is flipped, the OmitCompileDetector and msarson#733 ones now use a COMPILE, and an OMIT counterpart is added. Server suite: 4569 passing, 3 pending; the SDI disk cache test timed out under full load as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, the compiler test was the right call. I ran your cases and some more on Clarion 11.1 and Clarion 12 (both gave identical results), the same way: one project per case, each line assigning an undeclared Skipped block (
Compiled block (
Case: the match is case-sensitive in both modes. (A literal condition such as This fits the Language Reference: the compiler "reads and parses source/include files by blocks" and "either will skip the text up to terminator or will continue to parse the file – depending on whether you are using OMIT or COMPILE and what condition". Skipping, it searches the text; parsing, it sees strings as strings. The change: Tests: the two "a terminator in a string in code does not close" guard tests you pointed out now assert the skipped rule, next to tests for the compiled one. 8 new tests in |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged, thanks. You were right about compiled blocks. I ran your compiled-block cases on both installs here:
Skipped blocks and the case-sensitive match behave the same on both versions. Following 11.1 and 12 is the right call; I'm only noting the C10 difference for the record. The reviewers had two small follow-ups, neither blocking:
— Alice |
What happened
A marker idiom used for debug-only code writes the COMPILE terminator quoted, in a comment:
or on one line, with the terminator in the directive line's own comment:
With
_Debug_off this compiles: the compiler ends the block on the comment line. (If it didn't, the rest of the module would be dropped and the build would fail.) The extension never ended it. Everything after the directive counted as not compiled, soSomeClass.incandOtherClass.incwere treated as not included, and the missing-include check reported the first variable of each class in the module:Root cause
scanConditionalCompile(#807) strips every quoted string from a line before it looks for the terminator, and that includes the comment:!'*Debug*'becomes!, so the terminator is gone. The rule was taken fromOmitCompileDetector, which has the same stripping. The rule exists so thatMESSAGE('***')doesn't close anOMIT('***'), and that still holds for strings in code. But a comment isn't code: the text after!is plain text.Separately, neither scan looked at the rest of the directive's own line, so the one-line form never closed either.
The fix
One shared test of a line, in
ConditionalCompile.ts. The code part has its strings removed and the comment part is searched as it is:code()is the existing helper that cuts a line at the first!outside a string, soMESSAGE('Hi! ***')stays code and does not close.scanConditionalCompileuses it for every line, and checks the rest of the directive line after the matched directive. A block that closes there opens and closes on that line:OmitCompileDetector.findDirectiveBlocksInLinesuses it in its terminator pass. It also checks the rest of the directive line, but only reads that line when its tokens go on after the closing), so OMIT body detection adds ~5 ms to every keystroke in a large module #733's "reads no line it does not need" still holds.OMIT('**Old**') ! the old waywas skipped like a conditional block and its body was not treated as omitted. The argument list now ends at), and a comment is not an argument. A conditional directive with a comment is still skipped (there is a test for this).''rather than nothing, as the detector already did, so that*'x'*does not join up into**. This changes nothing for the existing tests.Tests
ConditionalCompileTerminatorInComment.test.ts(new, 11 tests):MESSAGE('Hi! ***')still does not closeOmitCompileDetector:With the two source files reverted, 6 of the 11 fail and the 5 controls pass. The full server suite passes: 4562 passing, 0 failing, 3 pending. The existing #807 (
ConditionalCompile807), #733 (OmitKeystrokeCost733) andOmitCompileDetectortests are unchanged and pass.Scope
MESSAGE('***')in anOMIT('***')block)? Both scans assume so, and this PR keeps that assumption. It isn't compiler-checked here, and it would be worth confirming.🤖 Generated with Claude Code