Skip to content
Topazdocs

Search documentation

Specification 6.0

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Download →

    Design decisions

    Failure, concurrency and modules

    A Result error type needs an annotation when inference cannot determine it

    Adopted November 9, 2026 · 6.0.0 · Being verified

    Problem

    The success value may be visible without enough information to know which error type the function returns. A wide fallback would hide the constraint at call sites.

    Decision

    If inference cannot determine the error type, checking reports TPZ5022 and asks for a type annotation.

    Examples

    An unknown Result error type requires an annotation

    main.tpzAn unknown Result error type requires an annotation
    1. function value() { Ok(1) }
    2. let result = value()
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5022 →

      result-error-annotation-required at main.tpz:1:10

    A Result return annotation fixes the error type

    main.tpzA Result return annotation fixes the error typeOpen in Playground →
    1. import std.io
    2. function value() -> Result<int, string> { Ok(1) }
    3. let result = match (value()) {
    4. case Ok(number) => number
    5. case Err(_) => 0
    6. }
    7. io.writeLine("{result}")
    Expected outputExit code 0
    1
    
    $ topaz run main.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. 1

    Alternatives considered

    • Fall back to a dynamic value type. The return contract would no longer identify the possible error type.
    • Introduce a new diagnostic code. Return inference already has the rule and the code, so one form suffices.

    Why

    The same diagnostic as return inference identifies the annotation to add.

    Changed rules Annotating an unresolved Result error type →

    Partly answered pending items Return inference and nested callable contexts →

    A callback returns its own propagated error

    Adopted November 10, 2026 · 6.0.0 · Being verified

    Problem

    A lambda passed to map can use ?. Callers need to know whether that completes the lambda or leaves an enclosing function.

    Decision

    • When ? propagates from a lambda or callback, return Result or Option from that call.
    • If the Result error type cannot be inferred, checking reports TPZ5022 and requires a type annotation.

    Examples

    Mapping a propagating lambda produces an array of Results

    main.tpzMapping a propagating lambda produces an array of ResultsOpen in Playground →
    1. import std.io
    2. function surrounding() -> int {
    3. let inputs: Array<Result<int, string>> = [Ok(1), Err("stop"), Ok(3)]
    4. let advance: (Result<int, string>) -> Result<int, string> = (value) => {
    5. let number = value?
    6. io.writeLine("lambda {number}")
    7. Ok(number + 1)
    8. }
    9. let results: Array<Result<int, string>> = inputs.map(advance)
    10. io.writeLine("after map")
    11. for result in (results) {
    12. match (result) {
    13. case Ok(number) => io.writeLine("ok {number}")
    14. case Err(error) => io.writeLine("err {error}")
    15. }
    16. }
    17. 7
    18. }
    19. io.writeLine("{surrounding()}")
    Expected outputExit code 0
    lambda 1
    lambda 3
    after map
    ok 2
    err stop
    ok 4
    7
    
    $ topaz run main.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. lambda 1
    2. lambda 3
    3. after map
    4. ok 2
    5. err stop
    6. ok 4
    7. 7

    None returns from its lambda while the caller continues

    main.tpzNone returns from its lambda while the caller continues
    1. import std.io
    2. let advance: (Option<int>) -> Option<int> = (value) => {
    3. let number = value?
    4. io.writeLine("some {number}")
    5. Some(number + 1)
    6. }
    7. let missing = advance(None())
    8. io.writeLine("after none")
    9. match (missing) {
    10. case Some(number) => io.writeLine("{number}")
    11. case None() => io.writeLine("none")
    12. }
    13. let present = advance(Some(2))
    14. match (present) {
    15. case Some(number) => io.writeLine("{number}")
    16. case None() => io.writeLine("none")
    17. }
    Expected outputExit code 0
    after none
    none
    some 2
    3
    
    $ topaz run main.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. after none
    2. none
    3. some 2
    4. 3

    An integer-returning lambda cannot propagate a Result

    main.tpzAn integer-returning lambda cannot propagate a ResultOpen in Playground →
    1. let read: (Result<int, string>) -> int = (value) => {
    2. value?
    3. }
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5001 →

      propagation-requires-result-return at main.tpz:2:5

    Alternatives considered

    • Return nonlocally from the enclosing function. The function invoking the callback would have to handle nonlocal control flow.
    • Leave the destination of ? unspecified. Each function boundary needs one destination for ? so the same code reads the same way.

    Why

    The nearest callable body tells readers where ? returns.

    Changed rules Propagation returns from the current callable →

    Resolved pending items Return inference and nested callable contexts →

    An empty concurrent group returns an empty record

    Adopted November 7, 2026 · 6.0.0 · Being verified

    Problem

    Each concurrent arm contributes a result field. The language needs a result for a group with no arms as well.

    Decision

    • A concurrent group with no arms produces an empty record.
    • In a type position, {} denotes the empty record type. As an expression it is still a block that returns unit.

    Examples

    An untimed group may have no arms

    example.tpzAn untimed group may have no arms
    1. let joined = concurrent {}
    Expected outputExit code 0
    No stdout.
    $ topaz check example.tpz --language-version 6.0 --format json
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    An empty concurrent record passes through an explicit record signature

    example.tpzAn empty concurrent record passes through an explicit record signature
    1. import std.io
    2. function keep(value: {}) -> {} { value }
    3. let joined: {} = keep(concurrent {})
    4. io.writeLine("completed")
    Expected outputExit code 0
    completed
    
    $ topaz run example.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. completed

    The zero-field record is distinct from unit

    example.tpzThe zero-field record is distinct from unit
    1. let joined: () = concurrent {}
    Expected outputNonzero exit
    No stdout.
    $ topaz check example.tpz --language-version 6.0 --format json
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5001 →

      concurrent-empty-result-is-not-unit at example.tpz:1:18

    Alternatives considered

    • Require at least one arm. The result rule would need a special case at zero arms.

    Why

    The arm-to-field relationship also holds for an empty group.

    Changed rules Concurrent groups may contain zero arms →

    A timeout evaluates a Duration expression once

    Adopted November 7, 2026 · 6.0.0 · Being verified

    Problem

    A program may read its timeout from a setting or calculate it. Literal-only syntax would require rewriting code that already has the same duration as a value.

    Decision

    Accept an ordinary Duration expression. Evaluate it once before starting the deadline and the arms.

    Examples

    Parentheses preserve a timeout value

    example.tpzParentheses preserve a timeout value
    1. import std.io
    2. let joined = concurrent(timeout: (0ms)) { value: 1 } else { { value: 7 } }
    3. io.writeLine("{joined.value}")
    Expected outputExit code 0
    7
    
    $ topaz run example.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. 7

    A bound Duration is the same timeout value

    example.tpzA bound Duration is the same timeout value
    1. import std.io
    2. let budget: Duration = 0ms
    3. let joined = concurrent(timeout: budget) { value: 1 } else { { value: 7 } }
    4. io.writeLine("{joined.value}")
    Expected outputExit code 0
    7
    
    $ topaz run example.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. 7

    Evaluate the timeout once before any arm

    example.tpzEvaluate the timeout once before any arm
    1. import std.io
    2. function budget() -> Duration {
    3. io.writeLine("budget")
    4. 0ms
    5. }
    6. let joined = concurrent(timeout: budget()) {
    7. value: { io.writeLine("arm")
    8. 1 }
    9. } else {
    10. io.writeLine("fallback")
    11. { value: 7 }
    12. }
    13. io.writeLine("{joined.value}")
    Expected outputExit code 0
    budget
    fallback
    7
    
    $ topaz run example.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. budget
    2. fallback
    3. 7

    An integer does not implicitly become Duration

    example.tpzAn integer does not implicitly become Duration
    1. let joined = concurrent(timeout: 1) { value: 1 } else { { value: 7 } }
    Expected outputExit code 1
    No stdout.
    $ topaz check example.tpz --language-version 6.0
    Expected result

    Expected result

    Rejection during check. Exit code 1.

    • TPZ5001 →

      concurrent-timeout-duration-type at example.tpz:1:34

    Alternatives considered

    • Accept a literal only, as now. The same value would be rejected for being written with parentheses or a name.
    • Accept constant expressions only. An expression that computes the same value should be accepted too.

    Why

    Timeout arithmetic uses ordinary expressions with a defined evaluation point.

    Changed rules A timeout accepts a Duration expression →

    A deadline wins when completion coincides with it

    Adopted November 7, 2026 · 6.0.0 · Being verified

    Problem

    An arm may finish at the instant its deadline expires. The result depends on which event takes precedence.

    Decision

    • A timeout wins when completion coincides with the deadline. The rule also covers zero milliseconds.
    • Declaration order gives no priority to faults that occur simultaneously.

    Examples

    Zero duration takes the fallback for one ready arm

    example.tpzZero duration takes the fallback for one ready arm
    1. import std.io
    2. let joined = concurrent(timeout: 0ms) {
    3. value: 1
    4. } else {
    5. { value: 7 }
    6. }
    7. io.writeLine("{joined.value}")
    Expected outputExit code 0
    7
    
    $ topaz run example.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. 7

    Zero duration takes the complete fallback for multiple ready arms

    example.tpzZero duration takes the complete fallback for multiple ready armsOpen in Playground →
    1. import std.io
    2. let joined = concurrent(timeout: 0ms) {
    3. left: 1
    4. right: 2
    5. } else {
    6. { left: 7, right: 8 }
    7. }
    8. io.writeLine("{joined.left}:{joined.right}")
    Expected outputExit code 0
    7:8
    
    $ topaz run example.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. 7:8

    A zero-duration fallback can raise its own runtime fault

    example.tpzA zero-duration fallback can raise its own runtime fault
    1. function divide(divisor: int) -> int {
    2. 42 / divisor
    3. }
    4. let joined = concurrent(timeout: 0ms) {
    5. value: 1
    6. } else {
    7. { value: divide(0) }
    8. }
    Expected outputExit code 1
    No stdout.
    $ topaz run example.tpz --language-version 6.0
    Expected result

    Expected result

    Rejection during run. Exit code 1.

    Alternatives considered

    • Let a completion seen on the final poll win. The outcome would depend on polling timing instead of the deadline boundary.
    • Leave the result of a deadline race unspecified. The result of 0ms and simultaneous completion must be fixed for a program to repeat its result.

    Why

    Code can predict the timeout result at the boundary.

    Changed rules Deadline priority and competing faults →

    Resolved pending items Zero duration and competing outcomes →

    A concurrent arm cannot transfer control out of its boundary

    Adopted November 7, 2026 · 6.0.0 · Being verified

    Problem

    If one concurrent arm returns from an outer function, the behavior of its siblings also needs a rule. Control transfers entirely within the arm do not have that problem.

    Decision

    Reject return, loop control and error propagation statically when their target lies outside the arm.

    Examples

    Called functions and inner loops consume their own control transfer

    example.tpzCalled functions and inner loops consume their own control transferOpen in Playground →
    1. import std.io
    2. function advance(value: Result<int, string>) -> Result<int, string> {
    3. let number: int = value?
    4. return Ok(number + 1)
    5. }
    6. let joined = concurrent {
    7. result: advance(Err("missing"))
    8. count: {
    9. let mut count = 0
    10. while (count < 3) {
    11. count += 1
    12. if (count < 3) { continue }
    13. break
    14. }
    15. count
    16. }
    17. }
    18. match (joined.result) {
    19. case Ok(_) => io.writeLine("unexpected")
    20. case Err(message) => io.writeLine(message)
    21. }
    22. io.writeLine("{joined.count}")
    Expected outputExit code 0
    missing
    3
    
    $ topaz run example.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. missing
    2. 3

    An arm cannot return from its enclosing function

    example.tpzAn arm cannot return from its enclosing function
    1. function escape() -> int {
    2. let joined = concurrent {
    3. value: {
    4. return 1
    5. }
    6. }
    7. 0
    8. }
    Expected outputNonzero exit
    No stdout.
    $ topaz check example.tpz --language-version 6.0 --format json
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5001 →

      concurrent-arm-function-boundary at example.tpz:4:13

    An arm cannot break its enclosing loop

    example.tpzAn arm cannot break its enclosing loop
    1. while (true) {
    2. let joined = concurrent {
    3. value: {
    4. break
    5. }
    6. }
    7. break
    8. }
    Expected outputNonzero exit
    No stdout.
    $ topaz check example.tpz --language-version 6.0 --format json
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5001 →

      concurrent-arm-loop-boundary at example.tpz:4:13

    An arm cannot continue its enclosing loop

    example.tpzAn arm cannot continue its enclosing loop
    1. while (true) {
    2. let joined = concurrent {
    3. value: {
    4. continue
    5. }
    6. }
    7. break
    8. }
    Expected outputNonzero exit
    No stdout.
    $ topaz check example.tpz --language-version 6.0 --format json
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5001 →

      concurrent-arm-loop-boundary at example.tpz:4:13

    An arm cannot propagate a Result to its enclosing function

    example.tpzAn arm cannot propagate a Result to its enclosing function
    1. function escape(value: Result<int, string>) -> Result<int, string> {
    2. let joined = concurrent {
    3. result: value?
    4. }
    5. Ok(0)
    6. }
    Expected outputNonzero exit
    No stdout.
    $ topaz check example.tpz --language-version 6.0 --format json
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5001 →

      concurrent-arm-function-boundary at example.tpz:3:17

    Alternatives considered

    • Cancel sibling arms when control leaves the arm. One return would need additional rules for both the outer destination and sibling cancellation.
    • Define return and Result for an arm itself. It would not match the current runtime arm boundary and would need new control semantics.

    Why

    Readers can reason about each arm's control flow independently.

    Changed rules Each arm has its own control boundary →

    Resolved pending items Control transfer and propagation across an arm boundary →

    A timed group falls back even when a branch never finishes

    Adopted November 9, 2026 · 6.0.0 · Being verified

    Problem

    A branch may run in an infinite loop or recurse without returning. The caller needs to know both when the group can end and which external effects survive.

    Decision

    • A timed concurrent group takes its fallback when the deadline expires.
    • A host call already in progress runs to completion. Effects that already happened remain, and abandoned branches have no further effects after the group ends.
    • Untimed groups make no fairness guarantee.

    Examples

    A positive deadline ends an infinite loop

    main.tpzA positive deadline ends an infinite loopOpen in Playground →
    1. import std.io
    2. let joined = concurrent(timeout: 1ms) {
    3. value: {
    4. while (true) {}
    5. 0
    6. }
    7. } else {
    8. io.writeLine("fallback")
    9. { value: 7 }
    10. }
    11. io.writeLine("{joined.value}")
    Expected outputExit code 0
    fallback
    7
    
    $ topaz run main.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. fallback
    2. 7

    Alternatives considered

    • Interrupt a host call at the deadline. This would impose a separate interruption guarantee on synchronous host calls.
    • Guarantee fair scheduling for untimed groups. Routine code would pay for yield checks even without a timeout.

    Why

    A timeout gives callers a way out when a branch never completes.

    Changed rules Timed group progress →

    Partly answered pending items Deferred cleanup in abandoned arms →

    A branch abandoned at the deadline skips user cleanup

    Adopted November 10, 2026 · 6.0.0 · Being verified

    Problem

    Cleanup in a concurrent branch can itself take a long time or get stuck. The caller also needs to know what happens to a file the abandoned branch opened.

    Decision

    • An abandoned concurrent branch skips its remaining defer and using cleanup.
    • Language cleanup runs on normal exit and on return, break, continue, or error propagation through ?.
    • The runtime reclaims host resources opened by the abandoned branch when the group ends.

    Examples

    An abandoned arm skips its registered defer

    main.tpzAn abandoned arm skips its registered deferOpen in Playground →
    1. import std.io
    2. let joined = concurrent(timeout: 1ms) {
    3. value: {
    4. defer { io.writeLine("abandoned cleanup") }
    5. while (true) {}
    6. 0
    7. }
    8. } else {
    9. io.writeLine("fallback")
    10. { value: 7 }
    11. }
    Expected outputExit code 0
    fallback
    
    $ topaz run main.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. fallback

    A normally completed arm runs its defer before the result

    main.tpzA normally completed arm runs its defer before the resultOpen in Playground →
    1. import std.io
    2. let joined = concurrent(timeout: 10s) {
    3. value: {
    4. defer { io.writeLine("completed cleanup") }
    5. 7
    6. }
    7. } else {
    8. io.writeLine("fallback")
    9. { value: 0 }
    10. }
    11. io.writeLine("{joined.value}")
    Expected outputExit code 0
    completed cleanup
    7
    
    $ topaz run main.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. completed cleanup
    2. 7

    Completed cleanup followed by an abandoned arm

    main.tpzCompleted cleanup followed by an abandoned armOpen in Playground →
    1. import std.io
    2. let completed = concurrent {
    3. value: {
    4. defer { io.writeLine("completed cleanup") }
    5. 1
    6. }
    7. }
    8. let abandoned = concurrent(timeout: 1s) {
    9. value: {
    10. defer { io.writeLine("abandoned cleanup") }
    11. while (true) {}
    12. 0
    13. }
    14. } else {
    15. io.writeLine("fallback")
    16. { value: 0 }
    17. }
    Expected outputExit code 0
    completed cleanup
    fallback
    
    $ topaz run main.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. completed cleanup
    2. fallback

    Alternatives considered

    • Run cleanup in the abandoned branch. A stuck cleanup could keep the group open past its deadline.
    • Leave cleanup up to the implementation. The same program could produce different cleanup effects on different targets.

    Why

    A stalled cleanup in an abandoned branch cannot delay the caller further.

    Changed rules Deadline abandonment skips language cleanup →Runtime reclamation of abandoned arm handles →

    Resolved pending items Deferred cleanup in abandoned arms →

    Entry files and imported modules use the same statement rules

    Adopted November 7, 2026 · 6.0.0 · Being verified

    Problem

    A statement could run in an entry file and be skipped after that file was imported. Changing the file's role meant relearning when initialization happened.

    Decision

    • Use the same top-level statement rules for entry files and imports.
    • Initialize dependencies first, then ready modules in name order. Initialize each module once per execution and reject cycles before initialization with TPZ3006.

    Examples

    Free calls, assignments, and loops in an entry

    helpers.tpzFree calls, assignments, and loops in an entryOpen in Playground →
    1. import std.io
    2. export let value: int = 1
    3. let mut count: int = 0
    4. io.writeLine("free")
    5. for item in ([1]) {
    6. count = count + item
    7. io.writeLine("loop")
    8. }
    9. io.writeLine("{count}")
    Expected outputExit code 0
    free
    loop
    1
    
    $ topaz run helpers.tpz --language-version 6.0
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. free
    2. loop
    3. 1

    The same source file imported

    main.tpzThe same source file imported
    1. import helpers
    2. import std.io
    3. io.writeLine("{helpers.value}")
    Expected outputExit code 0
    free
    loop
    1
    1
    
    $ topaz run main.tpz --language-version 6.0
    helpers.tpzThe same source file imported
    1. import std.io
    2. export let value: int = 1
    3. let mut count: int = 0
    4. io.writeLine("free")
    5. for item in ([1]) {
    6. count = count + item
    7. io.writeLine("loop")
    8. }
    9. io.writeLine("{count}")
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. free
    2. loop
    3. 1
    4. 1

    Alternatives considered

    • Require a separate initialization function for imported files. Identical work would need different syntax in an entry file and a module.
    • Keep filtering statements in imported files as before. Statement rules would differ by file role.

    Why

    The same source rules say which statements run when a file is imported.

    Changed rules The same statements in every source file →Dependency order and one initialization →Reject cycles before initialization →

    User code cannot name compiler-generated declarations

    Adopted November 20, 2026 · 6.0.0 · In progress

    Problem

    The standard module std.lispex contains __PreparedLispexRuleCarrier, a type the compiler generates to implement the module's rule factories. When user code imported that name with import std.lispex { __PreparedLispexRuleCarrier }, the compiler stopped with an internal error instead of a diagnostic. No rule said whether user code could name a compiler-generated declaration.

    Decision

    • User code cannot name a declaration the compiler generates. This covers generated declarations in a standard module whose names start with __. The type of such a declaration reaches the public surface only through a public alias of that module, such as PreparedLispexRule, and that alias does not count as exposing a private type (TPZ3014).
    • When user code asks for such a name through a selected import or a namespace path, it gets TPZ3009 during name resolution, the same diagnostic as any other name the module does not export. It never becomes an internal error.
    • Only the implementation inside the same standard module and compiler-generated code use a generated declaration. A declaration with the same spelling in user code follows the ordinary rules, independent of this decision.

    Alternatives considered

    • Let user code name generated declarations. An implementation detail would become a user contract. In the current implementation, making this name public also stops working programs with an internal error.
    • Leave an import of a generated name as an internal error. An internal compiler error caused by user code breaks the diagnostic contract.

    Why

    The public surface is a contract users can rely on. If names the compiler generates for its implementation leak out, every change to that implementation breaks user programs.

    Changed rules Public and private declarations →Namespace imports and selected exports →Visibility through a namespace →

    Export let binds names with an ordinary pattern

    Adopted November 7, 2026 · 6.0.0 · Being verified

    Problem

    Exporting several destructured values one at a time can repeat initialization. The same pattern is useful whether its names are private or public.

    Decision

    • Use an ordinary immutable let pattern in export let. Export every name it binds.
    • Initialize once and install the bindings after a full match. Check their public types. A pattern binding no names produces TPZ2007.

    Examples

    Export every record binding after one initializer

    main.tpzExport every record binding after one initializer
    1. import lib
    2. import std.io { writeLine }
    3. writeLine("{lib.first}")
    4. writeLine("{lib.second}")
    Expected outputExit code 0
    init
    10
    20
    
    $ topaz run main.tpz --language-version 6.0
    lib.tpzExport every record binding after one initializer
    1. import std.io { writeLine }
    2. function make() -> { first: int, second: int } {
    3. writeLine("init")
    4. { first: 10, second: 20 }
    5. }
    6. export let { first: first, second: second } = make()
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. init
    2. 10
    3. 20

    An outer pattern annotation supplies each public binding type

    main.tpzAn outer pattern annotation supplies each public binding type
    1. import lib { count, label }
    2. let number: int = count
    3. let text: string = label
    Expected outputExit code 0
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    lib.tpzAn outer pattern annotation supplies each public binding type
    1. export let { nested: { count: count }, label: label }: { nested: { count: int }, label: string } = { nested: { count: 4 }, label: "four" }
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Export names from an ordinary nominal record pattern

    main.tpzExport names from an ordinary nominal record pattern
    1. import lib
    2. import std.io { writeLine }
    3. writeLine("{lib.first + lib.second}")
    Expected outputExit code 0
    42
    
    $ topaz run main.tpz --language-version 6.0
    lib.tpzExport names from an ordinary nominal record pattern
    1. record Pair { first: int, second: int }
    2. export let Pair { first: first, second: second } = Pair { first: 20, second: 22 }
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. 42

    Use plain let when a pattern publishes no binding

    main.tpzUse plain let when a pattern publishes no bindingOpen in Playground →
    1. export let _ = 1
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    Expected result

    Expected result

    Rejection during parse. Nonzero exit.

    Export preserves the ordinary refutable-let rejection

    main.tpzExport preserves the ordinary refutable-let rejection
    1. let maybe: Option<int> = None()
    2. export let Some(value) = maybe
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5026 →

      diagnostics-refutable-let-pattern at main.tpz:2:12

    Each bound name must have a public resolved type

    main.tpzEach bound name must have a public resolved type
    1. import lib
    2. let observed = lib.count
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    lib.tpzEach bound name must have a public resolved type
    1. record Hidden { value: int }
    2. export let { item: item, count: count } = { item: Hidden { value: 1 }, count: 2 }
    Expected result

    Expected result

    Rejection during resolve. Nonzero exit.

    • TPZ3014 →

      modules-public-private-nominal at lib.tpz:2:20

    Alternatives considered

    • Allow one name per exported let. Destructuring and declaration would need to be repeated to export the same data.
    • Name the exported bindings in a separate export list. Exporting should not require rewriting the destructuring.

    Why

    The structure used to unpack a value remains visible in its exports.

    Changed rules The shape of an exported binding →Exported bindings are immutable →

    Public declarations are checked after type resolution

    Adopted November 7, 2026 · 6.0.0 · Being verified

    Problem

    An exported function can state its type or let the compiler infer it. The choice should not affect whether it exposes a private type.

    Decision

    • Check the resolved types of public declarations. Exposing a module-private nominal type produces TPZ3014.
    • A transparent alias is allowed if its expanded type is public.

    Examples

    An explicit public result cannot expose a private nominal type

    main.tpzAn explicit public result cannot expose a private nominal type
    1. import lib
    2. let value = lib.make()
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    lib.tpzAn explicit public result cannot expose a private nominal type
    1. record Hidden { value: int }
    2. export function make() -> Hidden { Hidden { value: 7 } }
    Expected result

    Expected result

    Rejection during resolve. Nonzero exit.

    • TPZ3014 →

      modules-public-private-nominal at lib.tpz:2:27

    An inferred public result obeys the same visibility rule

    main.tpzAn inferred public result obeys the same visibility rule
    1. import lib
    2. let value = lib.make()
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    lib.tpzAn inferred public result obeys the same visibility rule
    1. record Hidden { value: int }
    2. export function make() { Hidden { value: 7 } }
    Expected result

    Expected result

    Rejection during resolve. Nonzero exit.

    • TPZ3014 →

      modules-public-private-nominal at lib.tpz:2:17

    An alias expansion cannot hide a private nominal result

    main.tpzAn alias expansion cannot hide a private nominal result
    1. import lib
    2. let value = lib.make()
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    lib.tpzAn alias expansion cannot hide a private nominal result
    1. record Hidden { value: int }
    2. type Alias = Hidden
    3. export function make() -> Alias { Hidden { value: 7 } }
    Expected result

    Expected result

    Rejection during resolve. Nonzero exit.

    • TPZ3014 →

      modules-public-private-nominal at lib.tpz:3:27

    A private alias of a public type is transparent

    main.tpzA private alias of a public type is transparent
    1. import lib
    2. let value: int = lib.count()
    Expected outputExit code 0
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    lib.tpzA private alias of a public type is transparent
    1. type Count = int
    2. export function count() -> Count { 1 }
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Alternatives considered

    • Require annotations on every exported declaration. Developers would have to repeat a result the compiler can already infer.
    • Keep checking only the written syntax instead of the resolved type. The result should not depend on whether an annotation was written.

    Why

    Visibility follows the actual type independently of annotation style.

    Changed rules Resolved public type visibility →

    Record defaults follow export visibility

    Adopted November 7, 2026 · 6.0.0 · Being verified

    Problem

    A record default can refer to a name in another module. A private-name exception would make the same access depend on where it appeared.

    Decision

    Apply ordinary module visibility to name access in record defaults.

    Examples

    Reject a private value in a record default

    main.tpzReject a private value in a record default
    1. import std.io
    2. import defaults
    3. record Item {
    4. value: int = defaults.seed
    5. }
    6. let item = Item {}
    7. io.writeLine("{item.value}")
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    defaults.tpzReject a private value in a record default
    1. export let visible: int = 0
    2. let seed: int = 41
    3. let mut state: int = 42
    4. type Secret = int
    Expected result

    Expected result

    Rejection during resolve. Nonzero exit.

    • TPZ3009 →

      record-default-private-immutable-member at main.tpz:4:27

    Use an exported value in a record default

    main.tpzUse an exported value in a record default
    1. import std.io
    2. import defaults
    3. record Item {
    4. value: int = defaults.seed
    5. }
    6. let item = Item {}
    7. io.writeLine("{item.value}")
    Expected outputExit code 0
    41
    
    $ topaz run main.tpz --language-version 6.0
    defaults.tpzUse an exported value in a record default
    1. export let visible: int = 0
    2. export let seed: int = 41
    3. let mut state: int = 42
    4. type Secret = int
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. 41

    A record default cannot read a private mutable value

    main.tpzA record default cannot read a private mutable value
    1. import defaults
    2. record Item {
    3. value: int = defaults.state
    4. }
    5. let item = Item {}
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    defaults.tpzA record default cannot read a private mutable value
    1. export let visible: int = 0
    2. let seed: int = 41
    3. let mut state: int = 42
    4. type Secret = int
    Expected result

    Expected result

    Rejection during resolve. Nonzero exit.

    • TPZ3009 →

      record-default-private-mutable-member at main.tpz:3:27

    A default value does not grant access to a private type

    main.tpzA default value does not grant access to a private type
    1. import defaults
    2. record Item {
    3. value: int = {
    4. let saved: defaults.Secret = 1
    5. saved
    6. }
    7. }
    8. let item = Item {}
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    defaults.tpzA default value does not grant access to a private type
    1. export let visible: int = 0
    2. let seed: int = 41
    3. let mut state: int = 42
    4. type Secret = int
    Expected result

    Expected result

    Rejection during resolve. Nonzero exit.

    • TPZ3009 →

      record-default-private-type-member at main.tpz:4:29

    Alternatives considered

    • Allow private names only inside defaults. The export boundary would depend on where the name was read.

    Why

    Visibility works the same way in defaults and ordinary access.

    Changed rules Record defaults respect module privacy →

    As changes the imported name

    Adopted November 7, 2026 · 6.0.0 · Being verified

    Problem

    A module or value can be imported under its original name. Repeating that name after as makes the reader compare two spellings before seeing that nothing changes.

    Decision

    Use as only when the name changes. Repeating the default name produces TPZ2009.

    Examples

    Reject a namespace alias repeating its default name

    main.tpzReject a namespace alias repeating its default name
    1. import lib as lib
    2. let result: int = lib.value
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    lib.tpzReject a namespace alias repeating its default name
    1. export let value: int = 1
    Expected result

    Expected result

    Rejection during parse. Nonzero exit.

    Omit the namespace alias to keep its default name

    main.tpzOmit the namespace alias to keep its default name
    1. import lib
    2. let result: int = lib.value
    Expected outputExit code 0
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    lib.tpzOmit the namespace alias to keep its default name
    1. export let value: int = 1
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Reject a selected alias repeating its source name

    main.tpzReject a selected alias repeating its source name
    1. import lib { value as value }
    2. let result: int = value
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    lib.tpzReject a selected alias repeating its source name
    1. export let value: int = 1
    Expected result

    Expected result

    Rejection during parse. Nonzero exit.

    Omit the selected alias to keep its source name

    main.tpzOmit the selected alias to keep its source name
    1. import lib { value }
    2. let result: int = value
    Expected outputExit code 0
    No stdout.
    $ topaz check main.tpz --language-version 6.0 --format json
    lib.tpzOmit the selected alias to keep its source name
    1. export let value: int = 1
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Alternatives considered

    • Allow a redundant alias. The same import would have both an aliased and unaliased spelling.
    • Require an alias on every import. One import should have one way to write it.

    Why

    An alias shows an actual rename.

    Changed rules An alias changes the local name →

    Imported values have immutable bindings

    Adopted November 9, 2026 · 6.0.0 · Being verified

    Problem

    A module may need to modify an array it imports. It needs to know how that differs from using an imported handle to an open file.

    Decision

    • An imported binding is immutable. let mut x = imported gives the importing module a separate mutable value.
    • Host resource handles such as an imported File share resource state.

    Examples

    A mutable local leaves the exported array unchanged

    main.tpzA mutable local leaves the exported array unchanged
    1. import std.io
    2. import helpers { items }
    3. let mut local = items
    4. local.push(3)
    5. io.writeLine("{items.length}:{local.length}")
    Expected outputExit code 0
    2:3
    
    $ topaz run main.tpz --language-version 6.0
    helpers.tpzA mutable local leaves the exported array unchanged
    1. export let items = [1, 2]
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. 2:3

    An imported array has an immutable root

    main.tpzAn imported array has an immutable root
    1. import helpers { items }
    2. items[0] = 9
    Expected outputNonzero exit
    No stdout.
    $ topaz check main.tpz --language-version 6.0
    helpers.tpzAn imported array has an immutable root
    1. export let items = [1, 2]
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5003 →

      bindings-assignment-to-immutable at main.tpz:2:1

    Why

    An importer can edit its own array without changing the value in the exporting module.

    Changed rules Imported values →Rebinding imported declarations →

    Resolved pending items Mutation through imported values →