Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

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

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

    Tools

    check

    Checks a selected Topaz compilation unit by parsing, resolving, and type checking it.

    Synopsis and input

    Link

    topaz check

    Synopsis
    1. topaz check [entry] [--format human|json] [--exports-json]

    Input

    With entry, check the selected source unit. Without an entry, use package mode and load topaz.toml from the selected package root. In package mode, --locked requires the lock root manifest hash to match the current manifest before compilation.

    Options and conflicts

    OptionDefaultContractConflicts
    --format human|jsonhuman

    Select human or JSON diagnostics for check. The shared format rule lists the commands that accept JSON output.

    None listed
    --exports-jsonNot specified

    On a clean checked unit, write its public export surface as one JSON object. Rejected on other commands.

    --profile
    --profile available-profileNot specified

    Select a recognized check profile. The installed distribution must include its required assets and execution support.

    --exports-json
    --compiler self|rustself

    Select the compiler. SELF is the default. The rust value selects the reference compiler.

    None listed
    --language-version 5.21Not specified

    Select the documented language mode.

    None listed
    --root dirNot specified

    Select the module/package root. For an explicit entry, the default root is its directory and the entry must be under the root.

    None listed
    --lockedNot specified

    Require the package lock check in package mode.

    None listed

    Output channels

    stdout

    For a clean checked unit, --exports-json writes one checked public export-surface JSON object to standard output and returns success.

    Resolver and checker diagnostics use standard error and make the unprofiled SELF check fail. Human success status uses standard output. A clean check in JSON diagnostic mode emits no human success banner. Diagnostic JSON, checked exports, and profile summaries are separate outputs.

    stderr

    Resolver and checker diagnostics use standard error and make the unprofiled SELF check fail. Human success status uses standard output. A clean check in JSON diagnostic mode emits no human success banner. Diagnostic JSON, checked exports, and profile summaries are separate outputs.

    Exit status

    0

    The selected compilation unit checks successfully.

    nonzero

    Options are invalid, the compilation product is invalid, or resolver/checker diagnostics are reported. Failures can use plain-text messages even in JSON diagnostic mode.

    Effects

    Checking does not execute the program. The check command defines package loading, root and lock handling, and filesystem effects.

    Operation

    Link
    Ruletopaz.rule.check.compilation-unit

    Checking a compilation unit

    check parses, resolves, and type checks the selected Topaz compilation unit. It does not run the checked program.

    Package selection, root and lock handling, and profiles follow the check command.

    Why

    Checking resolves and types the compilation unit before execution. Keeping execution separate lets callers validate code without running its effects.

    Source evidence

    Options and conflicts

    Link
    Ruletopaz.rule.check.exports-option

    Scope of --exports-json

    --exports-json applies to check. Using it with run is rejected during command validation before the program executes.

    Why

    --exports-json describes the checked export surface. Rejecting it for other commands prevents an accepted flag from silently doing nothing.

    Source evidence
    Ruletopaz.rule.check.json-option

    Diagnostic JSON option

    Use --format json for check diagnostics. check --json is rejected; it is not an alias for --format json.

    The shared format rule defines the commands that accept JSON output.

    Why

    --format json names the diagnostic format explicitly. Rejecting --json on check avoids a second spelling for the same request.

    Source evidence

    --format json and --exports-json are not mutually exclusive in the reviewed validator. --profile cannot be combined with --exports-json. A concrete profile example requires verified membership in the selected default distribution.

    Results and output channels

    Link
    Ruletopaz.rule.check.exports

    Checked export output

    For a clean checked unit, --exports-json writes one checked public export-surface JSON object to standard output and returns success.

    The complete export schema follows the check command.

    Why

    Tools need the checked public names and types without executing their module. A JSON object makes that interface available as structured data.

    Source evidence
    Ruletopaz.rule.check.channels

    Diagnostic and success channels

    Resolver and checker diagnostics use standard error and make the unprofiled SELF check fail. Human success status uses standard output. A clean check in JSON diagnostic mode emits no human success banner. Diagnostic JSON, checked exports, and profile summaries are separate outputs.

    Diagnostic and profile-summary fields follow the check command.

    The clean JSON example asserts empty output streams. The primitive mismatch example checks a diagnostic on standard error and empty standard output. The safe command recipe checks successful exit without asserting human output bytes.

    Why

    Separate channels let callers pipe successful output without mixing it with diagnostics. Suppressing the success banner keeps JSON output parseable.

    Source evidence

    A profile check has additional output behavior and must carry its profile identity. The reviewed SELF path emits a profile summary on standard output in JSON mode. That object is separate from the checked export surface.

    Examples

    Link

    Check the first program

    Link
    first-program.tpzCheck the first programOpen in Playground
    1. import std.io
    2. function greet(name: string) -> string {
    3. return "Hello, {name}!"
    4. }
    5. io.writeLine(greet("Topaz"))
    Recorded outputexit 0
    first-program.tpz: types-ok (2 modules)
    first-program.tpz: resolve-ok (2 modules)
    
    $ topaz check first-program.tpz --compiler self · recorded with topaz 5.21.3
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Observed assertions · passed · 5.21.3

    Exit code 0.

    Observed stdout
    1. first-program.tpz: types-ok (2 modules)
    2. first-program.tpz: resolve-ok (2 modules)

    No stderr.

    • Passed · expected 0; observed 0
    Observed assertions · passed · 5.21.3

    Exit code 0.

    Observed stdout
    1. first-program.tpz: types-ok (2 modules)
    2. first-program.tpz: resolve-ok (2 modules)

    No stderr.

    • Passed · expected 0; observed 0
    Source evidence

    Check and emit export JSON

    Link
    first-program.tpzCheck and emit export JSONOpen in Playground
    1. import std.io
    2. function greet(name: string) -> string {
    3. return "Hello, {name}!"
    4. }
    5. io.writeLine(greet("Topaz"))
    Expected outputexit 0
    $ topaz check first-program.tpz --compiler self --format json --exports-json · target product 5.21.3
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Standard output is a JSON object. Its complete schema is not specified.

    This example checks one JSON object on standard output. The check command defines its complete export schema and distinguishes unknown metadata from an empty export list.

    Source evidence

    Reject --exports-json on run

    Link
    first-program.tpzReject --exports-json on runOpen in Playground
    1. import std.io
    2. function greet(name: string) -> string {
    3. return "Hello, {name}!"
    4. }
    5. io.writeLine(greet("Topaz"))
    Recorded output excerptexit 1
    No stdout.
    topaz: `--compiler self` accepts `--exports-json` only on `check`
    
    topaz — Topaz toolchain developer driver (run `topaz --version`)
    
    USAGE:
        topaz <COMMAND> [ARGS]
    
    COMMANDS:
        parse <file>      parse a Topaz source file and report diagnostics
        dump-ast <file>   parse a Topaz source file and print the AST
        check [entry]     parse + resolve + type a selected compilation unit
                          (no entry = package mode from topaz.toml)
        run [entry]       execute a checked program (no entry = package mode)
        test [entry]      run a checked selected unit on the deterministic TestHost
                          (--root <package> keeps its manifest, lock, and dependencies
                          for a selected entry; no entry uses the manifest entry)
        fmt [entry]       parse-gated deterministic whitespace formatting
                          (`--check` reports drift without writing;
                          no entry = package mode; skips vendor/target)
        lsp               run the deterministic stdio language server; package
                          diagnostics use initialize.rootUri (or --root) with a
                          valid locked package and open-document overlays
        emit [entry]      expose generated Rust source for inspection/integration
                          (`--target rust`); print the primary source to stdout,
                          or write the complete source set with --out-dir <dir>
                          (--root <dir>; no entry = package mode)
        build [entry]     lower + scaffold (--out-dir <dir>, required) + drive
                          cargo to build a native binary at
                          <dir>/target/<profile>/program (final binary only), or with
                          --target web a wasm package at <dir>/topaz-web.wasm
                          (--target web-worker also emits worker glue)
                          (--release for an optimized build; --run to execute
                          native builds after building; no entry = package mode)
        init              scaffold a deterministic current-profile native package
                          at --root (default `.`); refuses to overwrite existing
                          files
        add <dep>         add a dependency to topaz.toml (`name@version`, or
                          `name --path <relative-path>` with content hash)
        lock              write deterministic topaz.lock for the package at
                          --root (default `.`); local/path dependency hashes must
                          already match topaz.toml
        fetch             fetch registry dependencies from --from <local-registry>
                          into vendor/<name>/<version>, verify content, write lock
        vendor            copy registry dependencies from --from <local-registry>
                          into vendor/<name>/<version>, verify content, write lock
        doc               generate deterministic package docs into --out-dir
        bench [entry]     time the resolve + type-check pipeline without running
                          user code (no entry = package mode)
        compiler observe [entry]
                          write canonical observations through generated Rust source
                          to --out-dir (no entry = package mode)
        compiler preview [entry]
                          run the linked self compiler and
                          write a typed-terminal observation to --out-dir;
                          add --producer stage1|stage2 --terminal rust-source for
                          an explicit compiler producer; Stage 2 also accepts
                          --self-source to compile the embedded compiler source set
        compiler validate <dir>
                          validate an observation bundle without recompiling
        compiler compare <left> <right>
                          compare two validated observations (semantic by default);
                          use --layer generated-source|provenance, or compare two
                          binary files with --layer native-binary
        compiler status   report the installed Topaz compiler and reference compiler
                          support (`--json` emits topaz.compiler-supp
    $ topaz run first-program.tpz --compiler self --exports-json · recorded with topaz 5.21.3
    Expected result

    Expected result

    Rejection during command. Nonzero exit.

    Observed assertions · passed · 5.21.3

    Exit code 1.

    No stdout.

    Observed stderr (excerpt)
    1. topaz: `--compiler self` accepts `--exports-json` only on `check`
    2. topaz — Topaz toolchain developer driver (run `topaz --version`)
    3. USAGE:
    4. topaz <COMMAND> [ARGS]
    5. COMMANDS:
    6. parse <file> parse a Topaz source file and report diagnostics
    7. dump-ast <file> parse a Topaz source file and print the AST
    8. check [entry] parse + resolve + type a selected compilation unit
    9. (no entry = package mode from topaz.toml)
    10. run [entry] execute a checked program (no entry = package mode)
    11. test [entry] run a checked selected unit on the deterministic TestHost
    12. (--root <package> keeps its manifest, lock, and dependencies
    13. for a selected entry; no entry uses the manifest entry)
    14. fmt [entry] parse-gated deterministic whitespace formatting
    15. (`--check` reports drift without writing;
    16. no entry = package mode; skips vendor/target)
    17. lsp run the deterministic stdio language server; package
    18. diagnostics use initialize.rootUri (or --root) with a
    19. valid locked package and open-document overlays
    20. emit [entry] expose generated Rust source for inspection/integration
    21. (`--target rust`); print the primary source to stdout,
    22. or write the complete source set with --out-dir <dir>
    23. (--root <dir>; no entry = package mode)
    24. build [entry] lower + scaffold (--out-dir <dir>, required) + drive
    25. cargo to build a native binary at
    26. <dir>/target/<profile>/program (final binary only), or with
    27. --target web a wasm package at <dir>/topaz-web.wasm
    28. (--target web-worker also emits worker glue)
    29. (--release for an optimized build; --run to execute
    30. native builds after building; no entry = package mode)
    31. init scaffold a deterministic current-profile native package
    32. at --root (default `.`); refuses to overwrite existing
    33. files
    34. add <dep> add a dependency to topaz.toml (`name@version`, or
    35. `name --path <relative-path>` with content hash)
    36. lock write deterministic topaz.lock for the package at
    37. --root (default `.`); local/path dependency hashes must
    38. already match topaz.toml
    39. fetch fetch registry dependencies from --from <local-registry>
    40. into vendor/<name>/<version>, verify content, write lock
    41. vendor copy registry dependencies from --from <local-registry>
    42. into vendor/<name>/<version>, verify content, write lock
    43. doc generate deterministic package docs into --out-dir
    44. bench [entry] time the resolve + type-check pipeline without running
    45. user code (no entry = package mode)
    46. compiler observe [entry]
    47. write canonical observations through generated Rust source
    48. to --out-dir (no entry = package mode)
    49. compiler preview [entry]
    50. run the linked self compiler and
    51. write a typed-terminal observation to --out-dir;
    52. add --producer stage1|stage2 --terminal rust-source for
    53. an explicit compiler producer; Stage 2 also accepts
    54. --self-source to compile the embedded compiler source set
    55. compiler validate <dir>
    56. validate an observation bundle without recompiling
    57. compiler compare <left> <right>
    58. compare two validated observations (semantic by default);
    59. use --layer generated-source|provenance, or compare two
    60. binary files with --layer native-binary
    61. compiler status report the installed Topaz compiler and reference compiler
    62. support (`--json` emits topaz.compiler-supp
    • Passed · expected nonzero; observed 1
    • Passed · stdout matches the authored expectation
    • Passed · command validation; cause exports-json-requires-check; no source location applies
    Source evidence

    Reject --json on check

    Link
    first-program.tpzReject --json on checkOpen in Playground
    1. import std.io
    2. function greet(name: string) -> string {
    3. return "Hello, {name}!"
    4. }
    5. io.writeLine(greet("Topaz"))
    Recorded output excerptexit 1
    No stdout.
    topaz: `--json` applies to `compiler status`, `explain`, and `bench` only; use `topaz lispex embed info --json` for the embedded evaluator
    
    topaz — Topaz toolchain developer driver (run `topaz --version`)
    
    USAGE:
        topaz <COMMAND> [ARGS]
    
    COMMANDS:
        parse <file>      parse a Topaz source file and report diagnostics
        dump-ast <file>   parse a Topaz source file and print the AST
        check [entry]     parse + resolve + type a selected compilation unit
                          (no entry = package mode from topaz.toml)
        run [entry]       execute a checked program (no entry = package mode)
        test [entry]      run a checked selected unit on the deterministic TestHost
                          (--root <package> keeps its manifest, lock, and dependencies
                          for a selected entry; no entry uses the manifest entry)
        fmt [entry]       parse-gated deterministic whitespace formatting
                          (`--check` reports drift without writing;
                          no entry = package mode; skips vendor/target)
        lsp               run the deterministic stdio language server; package
                          diagnostics use initialize.rootUri (or --root) with a
                          valid locked package and open-document overlays
        emit [entry]      expose generated Rust source for inspection/integration
                          (`--target rust`); print the primary source to stdout,
                          or write the complete source set with --out-dir <dir>
                          (--root <dir>; no entry = package mode)
        build [entry]     lower + scaffold (--out-dir <dir>, required) + drive
                          cargo to build a native binary at
                          <dir>/target/<profile>/program (final binary only), or with
                          --target web a wasm package at <dir>/topaz-web.wasm
                          (--target web-worker also emits worker glue)
                          (--release for an optimized build; --run to execute
                          native builds after building; no entry = package mode)
        init              scaffold a deterministic current-profile native package
                          at --root (default `.`); refuses to overwrite existing
                          files
        add <dep>         add a dependency to topaz.toml (`name@version`, or
                          `name --path <relative-path>` with content hash)
        lock              write deterministic topaz.lock for the package at
                          --root (default `.`); local/path dependency hashes must
                          already match topaz.toml
        fetch             fetch registry dependencies from --from <local-registry>
                          into vendor/<name>/<version>, verify content, write lock
        vendor            copy registry dependencies from --from <local-registry>
                          into vendor/<name>/<version>, verify content, write lock
        doc               generate deterministic package docs into --out-dir
        bench [entry]     time the resolve + type-check pipeline without running
                          user code (no entry = package mode)
        compiler observe [entry]
                          write canonical observations through generated Rust source
                          to --out-dir (no entry = package mode)
        compiler preview [entry]
                          run the linked self compiler and
                          write a typed-terminal observation to --out-dir;
                          add --producer stage1|stage2 --terminal rust-source for
                          an explicit compiler producer; Stage 2 also accepts
                          --self-source to compile the embedded compiler source set
        compiler validate <dir>
                          validate an observation bundle without recompiling
        compiler compare <left> <right>
                          compare two validated observations (semantic by default);
                          use --layer generated-source|provenance, or compare two
                          binary files with --layer native-binary
        compiler status   report the installed Topaz compiler and reference c
    $ topaz check first-program.tpz --compiler self --json · recorded with topaz 5.21.3
    Expected result

    Expected result

    Rejection during command. Nonzero exit.

    Observed assertions · passed · 5.21.3

    Exit code 1.

    No stdout.

    Observed stderr (excerpt)
    1. topaz: `--json` applies to `compiler status`, `explain`, and `bench` only; use `topaz lispex embed info --json` for the embedded evaluator
    2. topaz — Topaz toolchain developer driver (run `topaz --version`)
    3. USAGE:
    4. topaz <COMMAND> [ARGS]
    5. COMMANDS:
    6. parse <file> parse a Topaz source file and report diagnostics
    7. dump-ast <file> parse a Topaz source file and print the AST
    8. check [entry] parse + resolve + type a selected compilation unit
    9. (no entry = package mode from topaz.toml)
    10. run [entry] execute a checked program (no entry = package mode)
    11. test [entry] run a checked selected unit on the deterministic TestHost
    12. (--root <package> keeps its manifest, lock, and dependencies
    13. for a selected entry; no entry uses the manifest entry)
    14. fmt [entry] parse-gated deterministic whitespace formatting
    15. (`--check` reports drift without writing;
    16. no entry = package mode; skips vendor/target)
    17. lsp run the deterministic stdio language server; package
    18. diagnostics use initialize.rootUri (or --root) with a
    19. valid locked package and open-document overlays
    20. emit [entry] expose generated Rust source for inspection/integration
    21. (`--target rust`); print the primary source to stdout,
    22. or write the complete source set with --out-dir <dir>
    23. (--root <dir>; no entry = package mode)
    24. build [entry] lower + scaffold (--out-dir <dir>, required) + drive
    25. cargo to build a native binary at
    26. <dir>/target/<profile>/program (final binary only), or with
    27. --target web a wasm package at <dir>/topaz-web.wasm
    28. (--target web-worker also emits worker glue)
    29. (--release for an optimized build; --run to execute
    30. native builds after building; no entry = package mode)
    31. init scaffold a deterministic current-profile native package
    32. at --root (default `.`); refuses to overwrite existing
    33. files
    34. add <dep> add a dependency to topaz.toml (`name@version`, or
    35. `name --path <relative-path>` with content hash)
    36. lock write deterministic topaz.lock for the package at
    37. --root (default `.`); local/path dependency hashes must
    38. already match topaz.toml
    39. fetch fetch registry dependencies from --from <local-registry>
    40. into vendor/<name>/<version>, verify content, write lock
    41. vendor copy registry dependencies from --from <local-registry>
    42. into vendor/<name>/<version>, verify content, write lock
    43. doc generate deterministic package docs into --out-dir
    44. bench [entry] time the resolve + type-check pipeline without running
    45. user code (no entry = package mode)
    46. compiler observe [entry]
    47. write canonical observations through generated Rust source
    48. to --out-dir (no entry = package mode)
    49. compiler preview [entry]
    50. run the linked self compiler and
    51. write a typed-terminal observation to --out-dir;
    52. add --producer stage1|stage2 --terminal rust-source for
    53. an explicit compiler producer; Stage 2 also accepts
    54. --self-source to compile the embedded compiler source set
    55. compiler validate <dir>
    56. validate an observation bundle without recompiling
    57. compiler compare <left> <right>
    58. compare two validated observations (semantic by default);
    59. use --layer generated-source|provenance, or compare two
    60. binary files with --layer native-binary
    61. compiler status report the installed Topaz compiler and reference c
    • Passed · expected nonzero; observed 1
    • Passed · stdout matches the authored expectation
    • Passed · command validation; cause json-is-not-check-format; no source location applies
    Source evidence

    Keep the check diagnostic format

    Link
    main.tpzKeep the check diagnostic formatOpen in Playground
    1. let value = 1
    Expected outputexit 0
    No stdout.
    $ topaz check main.tpz --language-version 5.21 --format json · target product 5.21.3
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Source evidence

    An integer is not implicitly a float

    Link
    example.tpzAn integer is not implicitly a floatOpen in Playground
    1. let value: float = 1
    Recorded outputexit 1
    No stdout.
    error[TPZ5001]: expected `float`, found `int`
     --> example.tpz:1:20
      |
    1 | let value: float = 1
      |                    ^
    
    example.tpz: 1 type diagnostic
    
    $ topaz check example.tpz --compiler self · recorded with topaz 5.21.3
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5001 types-int-not-float at example.tpz:1:20
    Observed assertions · passed · 5.21.3

    Exit code 1.

    No stdout.

    Observed stderr
    1. error[TPZ5001]: expected `float`, found `int`
    2. --> example.tpz:1:20
    3. |
    4. 1 | let value: float = 1
    5. | ^
    6. example.tpz: 1 type diagnostic
    • Passed · expected nonzero; observed 1
    • Passed · stdout matches the authored expectation
    • Passed · checking TPZ5001; cause types-int-not-float; primary location asserted; additional diagnostics allow
    • Passed · checking TPZ5001; cause types-int-not-float; primary location asserted; additional diagnostics allow
    Source evidence

    Small source invocation

    Link
    main.tpzSmall source invocationOpen in Playground
    1. function identity<T>(value: T) -> T {
    2. value
    3. }
    Expected outputexit 0
    $ topaz check main.tpz --language-version 5.21 · target product 5.21.3
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Reuse the complete generic declaration accepted by the pilot. A successful fixture does not settle generic-call or inference contracts.

    Source evidence

    Verification

    Link

    Related entries

    Link

    --exports-json requires check

    Family
    topaz-cli
    Phase
    command
    Operation
    option-validation
    Category
    exports-json-requires-check

    Cause and conditions

    --exports-json applies to check. Using it with run is rejected during command validation before the program executes.

    Response

    Use topaz check with --exports-json.

    Source evidence

    --json is not the check diagnostic format

    Family
    topaz-cli
    Phase
    command
    Operation
    option-validation
    Category
    json-is-not-check-format

    Cause and conditions

    Use --format json for check diagnostics. check --json is rejected; it is not an alias for --format json.

    Response

    Use --format json for check diagnostics and --exports-json for checked exports.

    Source evidence

    Functions and generics

    TPZ5523: Duplicate protocol bound

    std.io.writeLine

    Menu

    Download