Repository navigation
fix(diagnostics): no reports inside a COMPILE/OMIT block that does not compile - #866
Merged
msarson merged 1 commit intoNov 25, 2026
Conversation
…t compile
A diagnostic on a line inside COMPILE('***',SW) with SW off (by an
EQUATE, one from an earlier INCLUDE, or a project define) still showed:
the facade filter (msarson#255) only dropped unconditional OMIT bodies, and
conditional directives never become OmitCompileDetector blocks.
filterOmitted now also asks msarson#807's reading which lines do not compile
(inactiveCodeTest, the same scan and cache as inactiveIncludeLines). A
block whose switch is not known stays live, and a report on a directive
line always survives. Affects every validator.
New ConditionalCompileDiagnostics270.test.ts: 8 tests, 4 fail without
the fix; full server suite 4627 passing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
msarson
added a commit
that referenced
this pull request
Nov 25, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(diagnostics): no reports inside a COMPILE/OMIT block that does not compile
Part of #270 (phase 1, diagnostics only).
What happened
A program includes a class only when a project switch is on, and a module uses it under the same switch:
With
_PDF_=>offin the .cwproj's DefineConstants, #807/#812 correctly stop following the INCLUDE, but the member module still reports'PdfClass' is defined in 'PdfClass.inc' which is not included.onPdf PdfClass. The compiler never sees that line. The same holds for any validator on any line in a conditional block that does not compile: a switch set by an EQUATE in the file, by an EQUATE in an earlier INCLUDE, or by a project define.Root cause
The facade filter every validator passes through only dropped unconditional OMIT bodies,
DiagnosticProvider.filterOmitted:A conditional directive never becomes one of those blocks ("we cannot evaluate macros at analysis time"), so a file whose only directives are conditional even returned before looking. Its comment said "Conditional OMIT/COMPILE stays live (defines aren't evaluated yet)". Since #807/#812 they are:
scanConditionalCompile(...).isInactive(line)already decides every line, but onlyinactiveIncludeLinesused it, for INCLUDE lines.The fix
ConditionalIncludes.tskeeps the runs of lines that do not compile next to the INCLUDE lines, from the same scan and in the same cache entry, and exposes them:filterOmitteddrops a diagnostic when either the old detector or this test says its line does not compile. The directive lines that always keep their reports now come from the OMIT/COMPILE directive tokens, so a conditional directive's own report ("unterminated") survives too:The reading is done once per token list (a WeakMap keyed like
blocksMemo, checked against uri and version), so the ten or so validators of one pass share it. A block whose switch is not known stays live, as #807 reads it: the change only ever removes reports.Testing
New
ConditionalCompileDiagnostics270.test.ts, 8 tests throughDiagnosticProvider.validateDocument, with a live control line in each fixture:SW EQUATE(0), and OMIT withSW EQUATE(1): no report in the block.SW EQUATE(0)from an earlier INCLUDE: no report.SW=>offin a .cwproj's DefineConstants (the COMPILE/OMIT: decide conditions from the project's defines (.cwproj DefineConstants, .prj #pragma define) #812 harness): no report.inactiveCodeTestper line, over adjacent runs and a plain OMIT.Without the fix, the 4 "decided off" tests fail with the reported symptom. With the directive-line rule removed, its test fails. Full server suite: 4627 passing.
Scope
OmitCompileDetector.isLineOmittedWithBlockstreats only the lines between directive and terminator as omitted, so a report on code before the terminator (c = 3 !***) used to show and is now dropped. The compiler skips that line as well. The directive line itself is not affected, since a report there always survives.OmitCompileDetectoris not touched beyond a comment). Phase 1's other half, and the gray-out decoration (phase 2), are left for OMIT/COMPILE phase 2: define-driven conditional evaluation + editor gray-out decoration #270.🤖 Generated with Claude Code