A declaration and its pattern can each carry a type annotation. Repeating a type raises an unnecessary question about which annotation owns the binding.
Decision
Reject a declaration that uses both a binding annotation and a pattern annotation for the same binding.
Adopted November 18, 2026 · 6.0.0 · Being verified · Version 2
Problem
A function or local value sharing a constructor name can change what an existing use means. Accepting let UserId = 5 would make UserId a variable in calls and a constructor in patterns. Names hidden in other modules do not need to be reserved.
Decision
Write Choice.Empty() for a nullary variant. Reject conflicts with visible constructors in bindings, parameters, function names and patterns.
In a value position, None(1) calls the prelude constructor with too many arguments. Qualify a user enum's None with its enum name.
Binding a visible newtype constructor name produces TPZ5712 during checking. The name remains available as a type.
For aliased imports, check the visible alias. Different declarations in separate modules remain distinct.
Examples
A qualified nullary constructor keeps its parentheses
check · checking · Verification · not-run
example.tpzA qualified nullary constructor keeps its parenthesesOpen in Playground →
enum Choice { Empty }
let value: Choice=Choice.Empty()
Expected outputExit code 0
$ topaz check example.tpz --language-version 6.0
Expected result
Expected result
Checking accepts the program. Exit code 0.
No stderr.
This exact example has not been executed.
A let binding cannot replace the Some constructor
reject · checking · Verification · not-run
example.tpzA let binding cannot replace the Some constructor
Adopted November 18, 2026 · 6.0.0 · Being verified
Problem
let mut can fix an immutable binding. A discarded temporary or a detached method needs a different repair.
Decision
Checking reports TPZ5003 for an immutable root and points to its reference.
Discarding the result of a mutating call on a temporary produces TPZ5027 at the call.
Detaching a mutator produces TPZ5028 at the member access. For one access, detachment takes precedence over an immutable root, which takes precedence over a discarded temporary.
A local function name refers to one declaration throughout its block
Adopted November 19, 2026 · 6.0.0 · In progress
Problem
When an inner and outer function shared a name, one call site could invoke the outer function before the inner declaration ran and the inner function afterward. The checker and runtime sometimes picked different functions, so checks could pass even when their return types differed.
Decision
A local function declaration shadows an outer value with the same name throughout its block. Local functions in the same block can call each other regardless of declaration order.
An immediate read before the declaration produces TPZ3018 during name resolution.
A read in a function body, a lambda or another deferred expression produces TPZ5002 at runtime if the declaration has yet to execute.
A function resolves its outer names at the point where it is defined.
Names declared by let and const remain visible after their declarations. A repeated value name in one block produces TPZ5008 at the second declaration.
When an eligible constant expression such as const G = f refers to a function, G can be called before the declaration of f. An ordinary read cannot come before the declaration.
Alternatives considered
Make a function name visible only after its declaration. An earlier function could not call a later one, which breaks mutual recursion.
Initialize all local functions on entry to the block. Early calls would move initialization errors into function bodies. Local and module functions would follow different timing rules.
At runtime, choose the function with that name that is ready. One call site could invoke functions with different return types. The checked type could disagree with the value returned.
Why
Each reference has a stable target for checking and execution. Local functions can call each other, and initialization errors point to the failed read.
Early reads are diagnosed at their evaluation boundary
Adopted November 19, 2026 · 6.0.0 · Being verified
Problem
An initializer may refer to a binding declared later in the module. An earlier example labeled a read reached during execution as a check-time error.
Decision
A read before initialization in an immediately evaluated expression, such as a condition or match subject, produces TPZ3018 during name resolution.
If execution reaches such a read in a branch, pattern, guard, short-circuit right operand, optional call argument, loop body, or later comprehension step, it raises TPZ5002.
Nested expressions inherit their surrounding conditional boundary, even when the condition is a literal.
Matching evaluates pattern expressions as it reaches them
Adopted November 19, 2026 · 6.0.0 · In progress
Problem
In the range pattern (x? .. end()), the ? in the lower endpoint can return from the function before the upper endpoint runs. Treating the upper endpoint as immediate because the input is an integer wrongly rejects the program for declaration order. The same problem made while let behave differently from other conditions.
Decision
The expression providing the value follows its surrounding evaluation path. This covers the right side of = in let, if let and while let, the subject of match and the iterable in for.
An expression inside a pattern runs only when the matcher reaches it. Reading an uninitialized outer binding there produces TPZ5002 at runtime.
Source structure determines when a read occurs. The input type and literal value leave that classification unchanged.
The checker resolves names and checks types inside pattern expressions even when execution skips them.
A comprehension evaluates only its first source with the enclosing expression. Later sources, filters and the result expression evaluate during iteration.
Alternatives considered
Treat range endpoints as immediate when the input is known to be an integer. An early return in the lower endpoint or a failed outer pattern can skip the upper endpoint. This approach rejects valid programs.
Prove during type checking that execution reaches the endpoint. The diagnostic for a single read could move between name resolution, checking and runtime depending on whether the proof succeeds.
Why
Read the source to tell when an early read will fail. Type information and compiler rewrites leave the diagnostic phase unchanged.
A name refers to the same declaration in checking and execution
Adopted November 19, 2026 · 6.0.0 · In progress
Problem
In a function body, RoundingMode.HalfEven() read the standard RoundingMode before a module let with the same name was initialized, and that let afterward. A function could therefore pass checking and still return a value of a different type than its declared result. Whether the checker knew the type of a binding declared later depended on the order in which it visited declarations. An assignment to an immutable binding was rejected during checking or only at runtime, depending on declaration order.
Decision
Each place that uses a name has one target for its role, and checking and execution use that same target. The initialization state at runtime never changes it. An ordinary value name finds only value declarations in its lexical scope. Positions with their own syntax, such as constructor calls and type references, use their own lookup. The head of Name.member prefers a visible binding and refers to a type or standard static operation with that name only when no binding is visible. The same declaration with the same type arguments is one type, however it is spelled. When a binding holds a function value, the binding is the target, and the call reads the function from it at runtime.
An imported name is a top-level binding of the current module. Declaring that name again at module top level remains TPZ3008, and importing under an alias leaves the original spelling free. Standard names visible without an import, such as RoundingMode, Some and Show, live in a scope outside the module top level. A module top-level binding with the same name shadows such a name for every value reference in that module. Declarations inside a block keep the block scope rules.
Only a binder that was never created is left out as a target. A binder that collides with a constructor name is one example, and its name then refers to the outer declaration. A declaration with an error in its annotation or initializer remains the target and never hands the name to the next candidate. A name declared twice in one block reports TPZ5008 once. Each read or write of that name is judged against every visible candidate and adds only errors that every candidate would produce. These rules decide follow-up diagnostics in programs that already contain errors.
Readiness is checked on the chosen binding when execution first reads or writes it. Code that runs immediately at module top level and reads or writes an uninitialized binding gets TPZ3018 during name resolution. A delayed read in a function body or branch before initialization faults with TPZ5002 at runtime. An assignment is checked at the step of its evaluation order that first touches the binding. So x = value() and r.a = value() evaluate the right side first, while xs[0] = value() and x += value() read the target first. Unless name resolution rejects it first, changing an immutable binding by assignment or a mutating method call gets TPZ5003 during checking. Declaration order and whether the code runs make no difference.
The type of a target comes from its declaration, whether or not the checker has visited that declaration yet. Annotations and function signatures come first, and the rest is derived from initializers and function bodies in dependency order. A type that cannot be finite, such as one that must contain itself, is a contradiction and reports TPZ5001 at the expression that causes it. A cycle without enough information reports one TPZ5020 or TPZ5022 for each group of mutually dependent declarations. Only judgments that need the unknown type are deferred, and questions the declaration answers are still checked.
A binding that shadows a standard name can be renamed together with its references to an unused name. Each reference then keeps its target declaration, its static type, and whether it reads immediately or later. Roles set from outside, such as the entry point main or a public export name, must stay unchanged. A function value shows its name, as in <function Show>, so a program that picks its path from that text can behave differently after renaming.
Alternatives considered
Choose the target from the initialization state at runtime. One place could see declarations of different types, so a function that passes checking could return a value of another type.
Let checking and execution choose targets separately. The checked declaration and the executed declaration could differ, so the check would not describe the actual run.
Let a module binding shadow a standard name only after its declaration. A module function body already refers to module bindings declared later. Keeping that rule when a name matches a standard name requires shadowing across the whole module. Shadowing from the declaration onward is the block scope rule and still applies in blocks.
Reject a read with TPZ5020 while the checker has yet to learn the target's type. Whether a program is accepted would depend on the order in which the checker visits declarations.
Skip a declaration with an error and use the next candidate with that name. One annotation error would silently move the name to a standard declaration and produce misleading follow-up diagnostics.
Defer every judgment that depends on a constant expression reading a module let. The missing value would also stop checks that the known type can already answer.
Check the readiness of the assigned binding before the right side in every assignment. Assignments such as x = value() evaluate the right side first. Checking earlier would change that order and drop the right side's output and first fault.
Check write permission at runtime. An assignment to the same immutable let would be rejected during checking or postponed to runtime depending on declaration order.
Why
A program that passes checking runs with the declarations that were checked. What a name means at one place depends neither on execution order, nor on the order the checker visits declarations, nor on whether its spelling matches a standard name. Readiness is checked when execution actually reaches the binding, so evaluation order and the first effect stay the same.
Adopted November 16, 2026 · 6.0.0 · Being verified
Problem
After saving grid[i].push and changing i, it matters which cell the method updates. A read method and a mutator could capture different things under the same spelling.
Decision
Reject a detached mutator such as let add = xs.push during checking.
Use let add = (v) => xs.push(v) to defer the call. Read methods can still be obtained as values.
Let a detached mutator capture the receiver's variable or cell. Read methods would capture values while mutators capture variables. A changed index could make the method differ from a lambda.
Why
The lambda shows what will be evaluated and changed at the time of the call.
Adopted November 16, 2026 · 6.0.0 · Being verified
Problem
A call such as make().push(2) writes to a returned value with no binding to store it in. If the result is discarded as well, an intended update can silently do nothing.
Decision
Reject a mutating call that has no root binding and discards its result during checking.
A call that uses its result is allowed, as in let last = make().pop().
With no else, it was unclear whether a caller could use the value from the true branch. The checker and code generator could disagree on that value's type.
Decision
An if without an else returns () even in a value context. Discard the value of the true branch.
Examples
An omitted else discards values and preserves selected effects
run · runtime · Verification · not-run
example.tpzAn omitted else discards values and preserves selected effects
import std.io
let taken =if (true) {
io.writeLine("then")
7
}
let skipped =if (false) {
io.writeLine("unexpected")
9
}
io.writeLine("{taken}")
io.writeLine("{skipped}")
Expected outputExit code 0
then
()
()
$ topaz run example.tpz --language-version 6.0
Expected result
Expected result
Execution completes. Exit code 0.
No stderr.
Expected stdout
then
()
()
This exact example has not been executed.
A unit context accepts discarded non-unit branch values
check · checking · Verification · not-run
example.tpzA unit context accepts discarded non-unit branch values
if-without-else-result-type-mismatch at example.tpz:1:18
No stdout.
This exact example has not been executed.
Alternatives considered
Return a union of the true branch's type and unit. The checker would assign a different type from the unit value already produced in execution.
Require else in a value position when the then value is not unit. It would not fit statement use or the current code generation, which always produces unit.
Why
The true branch can perform effects without changing the result type.