Skip to content

Other analyses that report into Problems

Audience: everyone who edits · about 5 minutes · Prerequisites: Problems panel and checks

Other analyses that report into Problems

Four analyses run continuously and report into the same panel:

Analysis What it catches
Checks Per-concept rules written by the language: divide by zero, self-assignment, wrong argument counts, break outside a loop, unreachable code
Constraints Rules about individual slot values and where a concept may be placed. See Constraints and placement rules
Type system Optional and gradual type checking. See Type checking
Data-flow Possibly-uninitialized variables and unreachable code, below

Data-flow analysis

Data-flow analysis runs automatically and reports two kinds of problems.

Possibly-uninitialized variables. Applies to variables declared with varDecl(name, type) without an initial value. If the analysis cannot prove the variable is assigned before a read, the reference gets a warning. It is conservative about branches, loops and function boundaries. Bare x = expr assignments are not tracked (they follow Python's function-scope rule). Fix it by giving the declaration an initial value or assigning before the first use.

Code Result
varDecl(x, "number") then print(x) Warning on x: possibly uninitialized
varDecl(x, "number", 0) then print(x) Clean: has an initial value
varDecl(x, "number"), x = 5, print(x) Clean: definitely assigned

Unreachable code. Any statement after a definite terminator (return, break, continue or raise) in the same block is flagged, on the unreachable statement rather than the terminator. Code in nested blocks is not affected. Load the Python language tour sample and open its Data-Flow Walkthrough root to see both.

Spelling

Free text in languages that opt in (today, the entries of the Changelog language) is spell-checked and reported as warnings, using a bundled English (Hunspell) dictionary that is downloaded the first time it is needed. Alt+Enter on a flagged entry offers Replace "x" with "y" for each suggestion and Add "x" to dictionary; words you add are remembered in this browser. The Spell-check language preference chooses the language (English for now) or turns spell checking off; the change applies from the next edit.

An error raised by a run

When Run Program runs on a real Python and the program stops with an error, the statement that raised it gets a warning mark with the error's last line (Run error: ZeroDivisionError: division by zero), and the line in the Output pane goes to the same statement when you click it. It is a warning, so it never stops the next run; it goes away as soon as you edit the model or run again. The statement is found from the line number in Python's own report, so nothing is marked when that cannot be told (a program the generator re-flowed, or an error inside a library).

Checking the whole project

The Problems panel only lists the model you have open. To check everything:

  1. Choose Tools > Typechecker > Check Entire Project (Ctrl/⌘+K, T, C).
  2. A notification says either "Check Entire Project: no issues found across N root(s)." or the Problems panel opens with every issue, grouped by file.
  3. Click a row to open that model and jump to the node.

Notes:

  • Models whose language has not been loaded yet this session are skipped, and a warning says how many ("Skipped N model(s) with no language loaded yet this session — open them once to include them."). Open them once and run the check again.
  • A model that is not open has no live editor to resolve references from, so reference checks can report less than you would see after opening the model.
  • The rows for a project scan have a line number that is only the position in the list, not a real source line.
  • A clean re-run clears the markers a previous run left.

Checks that run only when you ask

Some checks are too slow to run on every keystroke, or only make sense on demand. A language marks those as manual. Tools > Typechecker > Run Checks… offers them (when a model of the project uses such a language) next to the ordinary checks: pick this model or the whole project. The command palette also has Run Manual Checks (open root only), Run Manual Checks on Model (every root of the active model) and Run Manual Checks on Project (every model). Results show with the other problems until you next edit. If the language has none you get "This language has no concept that runs its checks manually."; for the model and project variants the message is "No model here uses a language with a concept that runs its checks manually." (The Changelog language's node-reference checks are the bundled example.)

Assessments

Tools > Typechecker > Run Assessment… lets you pick a read-only analysis of the whole project:

  • Documentation coverage: how many functions, classes and similar statements carry documentation, with each undocumented one listed.
  • Unused declarations: names declared but never used. Names starting with _ are ignored.

The summary appears as a notification and the findings as information entries in the Problems panel; each one jumps to its node. Plugins can add more assessments. Show Model Dependencies… (same submenu) is a related read-only view of which models import which.

For language authors: where the rules live

The rules behind a problem are written in the Language Editor (Tools > Language Editor). Open a concept and use its aspect tabs: Types > Checking rules for checks, Rules > Constraints for slot constraints, and Rules > Placement for where a concept may go. See The Language Editor. A problem caused by a named rule can be traced back to it with Go to rule (an Alt+Enter entry on the node).