Diagnostics¶
The language server and tcl-check report the same diagnostic codes. Each
diagnostic has a code, message, severity, source, and source location.
Severity And Source¶
All diagnostics default to error, except resolution diagnostics,
possible value constraint failures, and environment conflicts (warning),
and unreachable-code, unused-variable, and unused-proc (hint). Metadata chooses
hint or information for missing-variable. Project rules and source comments can
change severity or disable diagnostics for files or commands;
see Diagnostic Controls.
The source field identifies the origin:
parser: Tcl syntax errors.analysis: command structure, resolution, and metadata checks.tcl-ls: invalid config entries or source directives.
Parser Diagnostics¶
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 incomplete or malformed.
Configuration And Directive Diagnostics¶
invalid-project-configA config declaration is unsupported, has invalid arguments, or uses dynamic values where static words are required. This also covers metadata and include errors found when validating
tcllsrc.tcl.invalid-diagnostic-directiveA diagnostic comment has invalid syntax or level, or a command directive has no following command in its Tcl body.
invalid-moduleA module comment has invalid syntax or names an unknown module.
Structural Diagnostics¶
malformed-ifA statically analyzable
ifcommand has an invalid word layout.malformed-switchA statically analyzable
switchcommand has an invalid option or branch layout.duplicate-procThe same qualified procedure name is declared more than once in the active workspace.
unreachable-codeA command cannot run because an earlier command always leaves the script or a statically known condition excludes its branch.
incompatible-environmentA known namespace value at a call conflicts with a condition required by the called procedure. Requirements come from guards on the path that defines the procedure.
Resolution Diagnostics¶
unresolved-commandA command call could not be resolved to a builtin, procedure, or command described by metadata.
ambiguous-commandA command name matched multiple procedure candidates.
unresolved-packageA
package requiretarget was not found in builtin metadata or discovered package roots.unresolved-variableA procedure-scoped variable reference could not be resolved confidently.
missing-variableMetadata requests a diagnostic for a referenced variable that is known to be missing before the command runs.
incr,append, andlappenduse a hint:Variable is first created here.These commands still create the variable. The check reports nothing when existence is unknown, including external globals and variable links. A later binding does not hide the hint.ambiguous-variableA procedure-scoped variable reference matched multiple bindings.
unused-variableA procedure variable or parameter has no known use. The hint marks the first binding with the editor’s unused tag. This includes unused local links made by
variable,global, andupvar. Initialising a namespace variable or writing through a link counts as use. Uses in another procedure do not use the local link.Names that start with
_are treated as intentional. Global and namespace variables are excluded because other files can use them. Dynamic scripts, variable names, local-variable inspection, and unknown calls with dynamic arguments can hide uses, so they suppress hints in their procedure. Literal variable names passed to unknown commands or procedures count as possible uses. Metadata must describe variable reads withrefand script arguments withenter tcl body. Literal text does not suppress hints based on its contents. This check does not detect individual unused assignments.unused-procA procedure whose final name starts with
_has no known use. The hint marks the procedure name with the editor’s unused tag. Public procedure names are excluded. Calls, renames, and literal callback names count as uses; a self-recursive call alone does not.In the editor, uses are checked across the same project files as Find References, including unopened
.tcl,.tm, and.testfiles. Project roots follow the workspace folders, project configuration, or Tcl package roots. The scan runs in the background and shares parsed files with Find References. Other diagnostics remain available while unused procedure hints wait for the scan. After a completed scan, ordinary edits reuse the text and parsed facts for unchanged project files. Metadata or configuration changes can require a rebuild.Tcl namespace resolution keeps same-named procedures in different namespaces separate. The check does not infer computed command names. A literal callback name counts as a possible use even when the receiving command’s implementation is unknown. For the batch checker, pass the project directory to include callers outside a single file’s dependencies.
Command And Metadata Diagnostics¶
wrong-argument-countA command call has too few or too many arguments for its known signatures.
invalid-argumentsThe argument count matches a signature, but the arguments do not match its required structure or literal values.
unknown-subcommandThe first positional argument does not match a known subcommand.
unknown-optionAn option does not match any declared option for the resolved command.
missing-option-valueAn option that requires a value has no following value.
invalid-regexA statically known pattern for
regexporregsubfails Tcl regular expression compilation.invalid-exprAn expression has invalid syntax within the supported expression grammar. The message gives the parser’s reason, followed by the expression text after known substitutions on a separate line. Reasons include invalid bare words, missing operands or operators, incomplete conditional expressions, and unclosed delimiters. The default severity is
warningwhen only some known expression texts fail this check.Possible expansionshows a failing alternative for a warning;Example expansionshows one when all alternatives fail. Syntax must be valid even in a branch skipped by a short-circuit operator.invalid-expr-operandA known operand does not satisfy an operator’s numeric, integer, truth, or list requirement. The default severity is
warningwhen only some known alternatives fail. Unknown inputs do not produce this diagnostic.invalid-valueA known value assigned by
setdoes not satisfy its@typeannotation. The default severity iswarningwhen only some known values fail. See Value Constraints for supported checks and examples.conflicting-embedded-languageMetadata
enterclauses select overlapping command bodies.unsupported-special-enterAn
enter bodyselector for a structured Tcl command does not select one existing script-body argument. See Metadata Syntax for selector rules.
Analysis Limits¶
Diagnostics depend on what static analysis can establish. Dynamic values can prevent a check, and metadata checks require sufficiently confident command resolution. The tools do not evaluate project Tcl code to detect runtime errors. Keep metadata current so checks reflect the commands available to the program.