Diagnostics¶
tcl-ls emits diagnostics from two stages:
the parser, which reports Tcl syntax and tokenization problems
the analysis pipeline, which reports structural and semantic issues in code that parsed successfully enough to continue analysis
The same diagnostic set is used by both tcl-check and the language server.
In CLI output you see the formatted message, code, and source context. In LSP
clients, diagnostics are published with code, source, severity, and
message fields.
Sources And Severity¶
Diagnostic source values:
parserfor syntax diagnosticsanalysisfor lowering, resolution, metadata-driven, and semantic diagnostics
Current severity conventions:
parser diagnostics are errors
malformed static command forms are errors
metadata and arity validation failures are errors
unresolved and ambiguous resolution results are warnings
Parser Diagnostics¶
These come directly from the Tcl parser:
unmatched-quoteA quoted word started with
"but did not close.unmatched-braceA braced word started with
{but did not close.unmatched-bracketA command substitution started with
[but did not close.malformed-variableA variable substitution such as
${name}is syntactically incomplete or malformed.
Structural Analysis Diagnostics¶
These are emitted while lowering and normalizing certain Tcl forms before the main semantic pass.
malformed-ifA statically analyzable
ifcommand has an invalid word layout.malformed-switchA statically analyzable
switchcommand has an invalid option or branch layout.
Semantic And Resolution Diagnostics¶
These are emitted by the semantic resolver and diagnostic checkers.
Warnings:
unresolved-commandA command call could not be resolved to a builtin command, procedure, or metadata-backed command.
ambiguous-commandA command name resolved to multiple procedure candidates.
unresolved-packageA
package requiretarget could not be found in builtin metadata or the discovered workspace/package roots.unresolved-variableA procedure-scoped variable reference could not be resolved confidently.
ambiguous-variableA procedure-scoped variable reference matched multiple bindings.
Hints:
unreachable-codeA later command in the same statically analyzed script cannot run because control flow always leaves the script first.
Errors:
duplicate-procThe same qualified procedure name is declared multiple times in the active workspace.
Metadata-Driven Command Diagnostics¶
These rely on builtin or project metadata for command shape and option parsing.
wrong-argument-countThe command call does not match any known arity for the resolved command.
unknown-subcommandThe first positional argument does not match a known subcommand for the resolved command.
unknown-optionAn option-like argument does not match any declared metadata option for the resolved command.
missing-option-valueA known metadata option that requires a value is missing that following value.
invalid-regexA statically known pattern for
regexporregsubfails Tcl regular expression compilation.
Practical Notes¶
The diagnostic set is intentionally conservative:
dynamic Tcl patterns may suppress diagnostics instead of guessing
metadata only drives checks when command resolution is confident enough
some issues that would require runtime evaluation are intentionally not reported
For the best results:
keep project metadata current
add
plugin-pathorlib-pathentries intcllsrc.tclwhen your project depends on custom DSLs or external package treesuse
uv run tcl-check --context-lines 2 path/to/projectwhen you need the most readable terminal diagnostics