Diagnostic and cause
LinkExtern declaration problem
- Family
- topaz
- Phase
- resolve
- Code
TPZ5030
Cause and conditions
Import each extern module by an identity declared in topaz.toml. A missing module under an already declared extern namespace is rejected as TPZ5030.
Related rule: Extern declaration problemResponse
Declare the extern interface in topaz.toml and check its names and signatures. Import the module identity that the package declares.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 761-769 - compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 795-795 - compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 126-137 - compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 785-805 - compiler/crates/topaz_cli/src/tests/externs.rs at
151141d7bb44· 1506-1535 - compiler/crates/topaz_cli/src/command/dispatch.rs at
151141d7bb44· 87-107 - compiler/crates/topaz_cli/src/compile/check.rs at
151141d7bb44· 116-145
Compiler phase: check/package.
Compiler explanation: An extern module or function declaration is missing, malformed, duplicated, or not declared for an imported extern module.
Message templates are Pending. The explanation above is not an observed CLI message.
Import each extern module by an identity declared in topaz.toml. A missing module under an already declared extern namespace is rejected as TPZ5030.
Extern declaration problem
Import each extern module by an identity declared in topaz.toml. A missing module under an already declared extern namespace is rejected as TPZ5030.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 126-137 - compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 785-805 - compiler/crates/topaz_cli/src/tests/externs.rs at
151141d7bb44· 1506-1535 - compiler/crates/topaz_cli/src/command/dispatch.rs at
151141d7bb44· 87-107 - compiler/crates/topaz_cli/src/compile/check.rs at
151141d7bb44· 116-145
Response
LinkDeclare the extern interface in topaz.toml and check its names and signatures. Import the module identity that the package declares.
Reproduction and verification
LinkRejected program
Linkimport host.missing { twice }export function main(args: Array<string>, stdin: string) -> Result<int, string> {Ok(0)}
No stdout.
[package]name = "diagnostic_extern"version = "0.1.0"language = "5.21"entry = "main.tpz"[extern.host.math]hash = "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"abi_hash = "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"[[extern.host.math.functions]]name = "twice"params = ["int"]result = "int"[extern.host.math.replay]fixture = "replay/host-math.jsonl"[extern.host.math.sandbox]kind = "replay"
{"module":"host.math","function":"twice","args":[{"$":"int","value":"21"}],"result":{"$":"int","value":"42"}}
Expected result
Expected result
Rejection during resolve. Nonzero exit.
TPZ5030diagnostics-undeclared-extern-module atmain.tpz:1:8
This complete package fixture uses invocationArgs without a positional source file.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 126-137 - compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 785-805 - compiler/crates/topaz_cli/src/tests/externs.rs at
151141d7bb44· 1506-1535 - compiler/crates/topaz_cli/src/command/dispatch.rs at
151141d7bb44· 87-107 - compiler/crates/topaz_cli/src/compile/check.rs at
151141d7bb44· 116-145
Repaired program
Linkimport host.math { twice }export function main(args: Array<string>, stdin: string) -> Result<int, string> {Ok(0)}
[package]name = "diagnostic_extern"version = "0.1.0"language = "5.21"entry = "main.tpz"[extern.host.math]hash = "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"abi_hash = "sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"[[extern.host.math.functions]]name = "twice"params = ["int"]result = "int"[extern.host.math.replay]fixture = "replay/host-math.jsonl"[extern.host.math.sandbox]kind = "replay"
{"module":"host.math","function":"twice","args":[{"$":"int","value":"21"}],"result":{"$":"int","value":"42"}}
Expected result
Expected result
Checking accepts the program. Exit code 0.
This complete package fixture uses invocationArgs without a positional source file.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 126-137 - compiler/crates/topaz_self_frontend/topaz/resolver/graph.tpz at
151141d7bb44· 785-805 - compiler/crates/topaz_cli/src/tests/externs.rs at
151141d7bb44· 1506-1535 - compiler/crates/topaz_cli/src/command/dispatch.rs at
151141d7bb44· 87-107 - compiler/crates/topaz_cli/src/compile/check.rs at
151141d7bb44· 116-145