Prerequisite
LinkUse a Topaz distribution that provides language mode 5.21 and the default SELF compiler.
1. Write a function
LinkSave the source in the check example below as first-program.tpz. The function returns a greeting. The final call sends it to std.io.writeLine. This example uses an explicit output operation; it does not depend on automatic printing of a top-level value.
2. Check the program
LinkCheck the first program
Linkimport std.iofunction greet(name: string) -> string {return "Hello, {name}!"}io.writeLine(greet("Topaz"))
first-program.tpz: types-ok (2 modules) first-program.tpz: resolve-ok (2 modules)
Expected result
Expected result
Checking accepts the program. Exit code 0.
Observed assertions · passed · 5.21.3
Exit code 0.
first-program.tpz: types-ok (2 modules)first-program.tpz: resolve-ok (2 modules)
No stderr.
- Passed · expected 0; observed 0
Observed assertions · passed · 5.21.3
Exit code 0.
first-program.tpz: types-ok (2 modules)first-program.tpz: resolve-ok (2 modules)
No stderr.
- Passed · expected 0; observed 0
Source evidence
- docs/npm/README.md at
d61f9fd0efb0· 48-79 - compiler/crates/topaz_cli/src/command/dispatch.rs at
d61f9fd0efb0· 86-128 - compiler/crates/topaz_resolve/src/std/521/io.tpz at
d61f9fd0efb0· 3-5
Expected result: checking succeeds. This step checks the program without running its output operation. If checking fails, follow the reported diagnostic code to Diagnostics. The check reference defines input, options, and output channels.
3. Run the program
LinkRun the first program
Linkimport std.iofunction greet(name: string) -> string {return "Hello, {name}!"}io.writeLine(greet("Topaz"))
Hello, Topaz!
Expected result
Expected result
Execution completes. Exit code 0.
Hello, Topaz!
Observed assertions · passed · 5.21.3
Exit code 0.
Hello, Topaz!
No stderr.
- Passed · expected 0; observed 0
- Passed · stdout matches the authored expectation
- Passed · stderr matches the authored expectation
Observed assertions · passed · 5.21.3
Exit code 0.
Hello, Topaz!
No stderr.
- Passed · expected 0; observed 0
- Passed · stdout matches the authored expectation
- Passed · stderr matches the authored expectation
Source evidence
- docs/npm/README.md at
d61f9fd0efb0· 48-79 - compiler/crates/topaz_cli/src/command/dispatch.rs at
d61f9fd0efb0· 137-153 - compiler/crates/topaz_resolve/src/std/521/io.tpz at
d61f9fd0efb0· 3-5 - compiler/crates/topaz_self_frontend/topaz/emitter/builtins.tpz at
d61f9fd0efb0· 32-40 - compiler/crates/topaz_value/src/value/runtime.rs at
d61f9fd0efb0· 634-654
The run command checks the selected unit before execution. The expected program output is shown above; an observation is displayed after the exact source is executed.
Verification
LinkPublic Topaz 5.21.3 checked and ran this program successfully in Docs run 42224592687, attempt 2. Both commands exited with code 0, and run printed the expected greeting. The new receipts preserve the observed output from the unchanged fixture and invocation. The earlier receipts remain available.