Diagnostic and cause
LinkNamespace used as value
- Family
- topaz
- Phase
- resolve
- Code
TPZ3012
Cause and conditions
Reading an imported namespace as a standalone value produces TPZ3012. Select an exported member instead.
Related rule: Trigger and repairResponse
Select an exported member, such as ns.member, before storing or passing the value.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 445-453 - compiler/crates/topaz_self_frontend/topaz/resolver/scopes_walk.tpz at
151141d7bb44· 725-725 - compiler/crates/topaz_self_frontend/topaz/resolver/scopes_walk.tpz at
151141d7bb44· 849-875 - TPZ3012 at
151141d7bb44
Compiler phase: resolve.
Compiler explanation: A module namespace binding appears where a runtime value is required.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
⟨value⟩is a namespace, not a value; it may appear only as⟨value⟩.Sourcemember
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ3012]:
nsis a namespace, not a value; it may appear only asns.member
The expression names the module namespace itself. A namespace provides member access and is not a runtime value.
Trigger and repair
Reading an imported namespace as a standalone value produces TPZ3012. Select an exported member instead.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/resolver/scopes_walk.tpz at
151141d7bb44· 849-875 - TPZ3012 at
151141d7bb44
Response
LinkSelect an exported member, such as ns.member, before storing or passing the value.
Reproduction and verification
LinkRejected program
Linkimport lib as nslet value = ns
No stdout.
export let member = 1
Expected result
Expected result
Rejection during resolve. Nonzero exit.
TPZ3012diagnostic-tpz3012 atexample.tpz:2:13
The expected diagnostic, cause, source location, and accompanying diagnostics are specified below. The verification status records whether this program has been run.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 445-453 - compiler/crates/topaz_self_frontend/topaz/resolver/scopes_walk.tpz at
151141d7bb44· 725-725 - compiler/crates/topaz_self_frontend/topaz/resolver/scopes_walk.tpz at
151141d7bb44· 849-875 - TPZ3012 at
151141d7bb44
Corrected program
Linkimport lib as nslet value = ns.member
export let member = 1
Expected result
Expected result
Checking accepts the program. Exit code 0.
This program applies the repair described above. The verification status records whether it has been run.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/resolver/scopes_walk.tpz at
151141d7bb44· 849-875 - TPZ3012 at
151141d7bb44