You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
compile: a nested /* */ inside a doxygen header truncates the header and emits code as SAS #1499
The compiler strips comments using everything between /** and the first*/, so a doxygen header containing a block comment of its own is truncated at that inner */. The remainder of the header - including any code in a usage example - is emitted as live SAS, and the file then fails somewhere else entirely with a misleading error.
Reproduction
A macro whose header has a nested comment in its usage section:
/** @file @brief Example @details Usage: %my_macro(outlib=web1) /* reaching here means the child completed */data_null_;
setwork.status;
run;
@param [in] outlib Outputlibref**/%macro my_macro(outlib=0);%putoutlib=&outlib;
%mendmy_macro;
After sasjs compile the compiled program starts mid-header:
/**, @file, @brief and the start of the usage block are gone, and that data _null_ step executes for real.
What it cost
The run failed several hundred lines later with ERROR: No matching %MACRO statement for this %MEND statement. - the truncated header text had disturbed the code following it - so the error named nothing near the cause. It took a bisect of the macro file to find that a comment was responsible.
Expected
Match the closing **/ rather than the first */ when stripping a doxygen block, or fail with a clear message when a header contains a nested block comment.
Suggestion
A @sasjs/lint rule flagging /* inside a doxygen header would catch this at author time, since compile-time detection is far from the author's edit. Happy to raise that separately if you would rather keep the two apart.
removeHeader strips to the first close marker, which is exactly where the SAS lexer ends the comment - so the compiled output was faithful to SAS, and the defect was that nothing said so. The header is now validated before stripping, and the error names the file, the line that closed the header, the line that opened the nested comment, and the lines that would run as SAS:
src/services/nested.sas: the doxygen header is closed at line 7, before its **/ terminator at line 11: the close marker on line 7 belongs to the block comment opened at line 6. SAS block comments do not nest, so lines 8-11 - including the header's closing **/ - would be compiled as SAS. Remove the block comment from the header, or move it below the header.
It is wired in removeHeader (macro leaves) and loadDependenciesFile (services, jobs, tests, files), so both the CLI and the server compile paths fail at the header rather than at deploy.
Not doing the alternative of matching **/ instead of the first close marker: that makes the compile pass on a file SAS still rejects, so the failure moves to run time with the same misleading error. Every doxygen header in core, cli and utils (636 of them) closes with **/ alone on its line and none contains a nested /*, so the check has no false positives on the corpus.
The @sasjs/lint rule from the suggestion is complementary and belongs in that repo - lint never sees dependency macros pulled from another project. Worth raising separately.
@sasjs/lint 4.4.0 (feat(lint): add the noNestedCommentsInHeader rule lint#265) - noNestedCommentsInHeader reports the author-time version of this, and hasDoxygenHeader now also reports a header closed with a single asterisk, with a fixer.
@sasjs/cli 6.2.4 (fix(compile): name the file when a header closes early #1500) - both compile paths pass the source path, so the error reads <file>: the doxygen header is closed at line N, before its **/ terminator at line M, and the CLI ships the lint rule.
Verified in the published tarball rather than only in git: @sasjs/[email protected]'s build/commands/compile/internal/loadDependencies.js passes filePath to removeHeader, build/commands/build/build.js does the same for the service member path, and the manifest resolves @sasjs/utils ^4.1.1 with @sasjs/lint ^4.4.0 as a peer.
Both lint rules default to WARNING, so upgrading does not change a project's lint return code; set "severityLevel": {"noNestedCommentsInHeader": "error"} to make it fatal. Closing.
Activity
sasjs-dev commentedon Oct 27, 2026
Compile-time fix raised in sasjs/utils#288.
removeHeaderstrips to the first close marker, which is exactly where the SAS lexer ends the comment - so the compiled output was faithful to SAS, and the defect was that nothing said so. The header is now validated before stripping, and the error names the file, the line that closed the header, the line that opened the nested comment, and the lines that would run as SAS:It is wired in
removeHeader(macro leaves) andloadDependenciesFile(services, jobs, tests, files), so both the CLI and the server compile paths fail at the header rather than at deploy.Not doing the alternative of matching
**/instead of the first close marker: that makes the compile pass on a file SAS still rejects, so the failure moves to run time with the same misleading error. Every doxygen header in core, cli and utils (636 of them) closes with**/alone on its line and none contains a nested/*, so the check has no false positives on the corpus.The
@sasjs/lintrule from the suggestion is complementary and belongs in that repo - lint never sees dependency macros pulled from another project. Worth raising separately.sasjs-dev commentedon Oct 27, 2026
Released across the three packages:
@sasjs/utils4.1.1 (fix(compile): fail when a doxygen header closes early utils#288) -removeHeaderfails instead of truncating, and names the file when it is given one.@sasjs/lint4.4.0 (feat(lint): add the noNestedCommentsInHeader rule lint#265) -noNestedCommentsInHeaderreports the author-time version of this, andhasDoxygenHeadernow also reports a header closed with a single asterisk, with a fixer.@sasjs/cli6.2.4 (fix(compile): name the file when a header closes early #1500) - both compile paths pass the source path, so the error reads<file>: the doxygen header is closed at line N, before its **/ terminator at line M, and the CLI ships the lint rule.Verified in the published tarball rather than only in git:
@sasjs/[email protected]'sbuild/commands/compile/internal/loadDependencies.jspassesfilePathtoremoveHeader,build/commands/build/build.jsdoes the same for the service member path, and the manifest resolves@sasjs/utils^4.1.1 with@sasjs/lint^4.4.0 as a peer.Both lint rules default to WARNING, so upgrading does not change a project's lint return code; set
"severityLevel": {"noNestedCommentsInHeader": "error"}to make it fatal. Closing.