Перейти к содержимому
Топаз6.0 · До релиза
Загрузка →

Поиск в документации

Спецификация 6.0

Выберите результат стрелками и нажмите Enter, чтобы открыть его.

Введите имя API, номер диагностики, правило или тему проекта.

    Инструменты

    check

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

    Synopsis and input

    Ссылка

    topaz check

    Форма вызова
    1. topaz check [entry] [--format human|json] [--exports-json]

    Ввод

    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.

    Параметры и конфликты

    ПараметрЗначение по умолчаниюКонтрактКонфликты
    --format human|jsonhuman

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

    Не перечислены
    --exports-jsonНе указано

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

    --profile
    --profile available-profileНе указано

    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.

    Не перечислены
    --language-version 5.21Не указано

    Select the documented language mode.

    Не перечислены
    --root dirНе указано

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

    Не перечислены
    --lockedНе указано

    Require the package lock check in package mode.

    Не перечислены

    Каналы вывода

    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.

    Статус завершения

    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.

    Эффекты

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

    Operation

    Ссылка
    Правилоtopaz.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.

    Причина

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

    Options and conflicts

    Ссылка
    Правилоtopaz.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.

    Причина

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

    Правилоtopaz.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.

    Причина

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

    --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

    Ссылка
    Правилоtopaz.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.

    Причина

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

    Правилоtopaz.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.

    Причина

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

    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

    Ссылка

    Check the first program

    Ссылка
    first-program.tpzCheck the first programОткрыть песочницу →
    1. import std.io
    2. function greet(name: string) -> string {
    3. return "Hello, {name}!"
    4. }
    5. io.writeLine(greet("Topaz"))
    Зафиксированный выводКод завершения 0
    first-program.tpz: types-ok (2 modules)
    first-program.tpz: resolve-ok (2 modules)
    
    $ topaz check first-program.tpz --compiler self · Зафиксировано с Топазом 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Проверка принимает программу. Код завершения 0.

    Наблюдаемые утверждения · Пройдено · 5.21.3

    Код завершения 0.

    Наблюдаемый стандартный вывод
    1. first-program.tpz: types-ok (2 modules)
    2. first-program.tpz: resolve-ok (2 modules)

    Нет вывода ошибок.

    • Пройдено · expected 0; observed 0
    Наблюдаемые утверждения · Пройдено · 5.21.3

    Код завершения 0.

    Наблюдаемый стандартный вывод
    1. first-program.tpz: types-ok (2 modules)
    2. first-program.tpz: resolve-ok (2 modules)

    Нет вывода ошибок.

    • Пройдено · expected 0; observed 0

    Check and emit export JSON

    Ссылка
    first-program.tpzCheck and emit export JSONОткрыть песочницу →
    1. import std.io
    2. function greet(name: string) -> string {
    3. return "Hello, {name}!"
    4. }
    5. io.writeLine(greet("Topaz"))
    Ожидаемый выводКод завершения 0
    $ topaz check first-program.tpz --compiler self --format json --exports-json · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Проверка принимает программу. Код завершения 0.

    Стандартный вывод содержит объект JSON. Полная схема не определена.

    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.

    Reject --exports-json on run

    Ссылка
    first-program.tpzReject --exports-json on runОткрыть песочницу →
    1. import std.io
    2. function greet(name: string) -> string {
    3. return "Hello, {name}!"
    4. }
    5. io.writeLine(greet("Topaz"))
    Фрагмент зафиксированного выводаКод завершения 1
    Нет стандартного вывода.
    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 · Зафиксировано с Топазом 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Этап отклонения command. Ненулевой код завершения.

    Наблюдаемые утверждения · Пройдено · 5.21.3

    Код завершения 1.

    Нет стандартного вывода.

    Фрагмент наблюдаемого вывода ошибок
    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
    • Пройдено · expected nonzero; observed 1
    • Пройдено · stdout matches the authored expectation
    • Пройдено · command validation; cause exports-json-requires-check; no source location applies

    Reject --json on check

    Ссылка
    first-program.tpzReject --json on checkОткрыть песочницу →
    1. import std.io
    2. function greet(name: string) -> string {
    3. return "Hello, {name}!"
    4. }
    5. io.writeLine(greet("Topaz"))
    Фрагмент зафиксированного выводаКод завершения 1
    Нет стандартного вывода.
    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 · Зафиксировано с Топазом 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Этап отклонения command. Ненулевой код завершения.

    Наблюдаемые утверждения · Пройдено · 5.21.3

    Код завершения 1.

    Нет стандартного вывода.

    Фрагмент наблюдаемого вывода ошибок
    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
    • Пройдено · expected nonzero; observed 1
    • Пройдено · stdout matches the authored expectation
    • Пройдено · command validation; cause json-is-not-check-format; no source location applies

    Keep the check diagnostic format

    Ссылка
    main.tpzKeep the check diagnostic formatОткрыть песочницу →
    1. let value = 1
    Ожидаемый выводКод завершения 0
    Нет стандартного вывода.
    $ topaz check main.tpz --language-version 5.21 --format json · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Проверка принимает программу. Код завершения 0.

    An integer is not implicitly a float

    Ссылка
    example.tpzAn integer is not implicitly a floatОткрыть песочницу →
    1. let value: float = 1
    Зафиксированный выводКод завершения 1
    Нет стандартного вывода.
    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 · Зафиксировано с Топазом 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Этап отклонения check. Ненулевой код завершения.

    Наблюдаемые утверждения · Пройдено · 5.21.3

    Код завершения 1.

    Нет стандартного вывода.

    Наблюдаемый вывод ошибок
    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
    • Пройдено · expected nonzero; observed 1
    • Пройдено · stdout matches the authored expectation
    • Пройдено · checking TPZ5001; cause types-int-not-float; primary location asserted; additional diagnostics allow
    • Пройдено · checking TPZ5001; cause types-int-not-float; primary location asserted; additional diagnostics allow

    Small source invocation

    Ссылка
    main.tpzSmall source invocationОткрыть песочницу →
    1. function identity<T>(value: T) -> T {
    2. value
    3. }
    Ожидаемый выводКод завершения 0
    $ topaz check main.tpz --language-version 5.21 · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Проверка принимает программу. Код завершения 0.

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

    Verification

    Ссылка

    Related entries

    Ссылка

    --exports-json requires check

    Семейство
    topaz-cli
    Этап
    command
    Операция
    option-validation
    Категория
    exports-json-requires-check

    Причина и условия

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

    Действия

    Use topaz check with --exports-json.

    --json is not the check diagnostic format

    Семейство
    topaz-cli
    Этап
    command
    Операция
    option-validation
    Категория
    json-is-not-check-format

    Причина и условия

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

    Действия

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

    Functions and generics →

    TPZ5523: Duplicate protocol bound →

    std.io.writeLine →

    Меню

    Загрузка →