Diagnostic and cause
LinkInitializer reads a later binding
- Family
- topaz
- Phase
- resolve
- Code
TPZ3018
Cause and conditions
During resolution, TPZ3018 reports a direct module initializer read of an uninitialized same-module runtime binding. See module initialization readiness and direct forward reads.
Response
Move the dependency before the initializer. For work intended to happen later, call a function after initialization completes.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 499-507 - compiler/crates/topaz_self_frontend/topaz/resolver/validation_init.tpz at
151141d7bb44· 809-809 - compiler/crates/topaz_self_frontend/topaz/resolver/validation_init.tpz at
151141d7bb44· 360-385 - compiler/crates/topaz_self_frontend/topaz/resolver/validation_init.tpz at
151141d7bb44· 453-469 - compiler/crates/topaz_self_frontend/topaz/resolver/validation_init.tpz at
151141d7bb44· 784-819 - TPZ3018 at
151141d7bb44
Compiler phase: resolve.
Compiler explanation: An imported-module initializer directly reads a later same-module runtime binding.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
- the initializer of
⟨value⟩reaches⟨value⟩, whose initializer has not completed (v5.2 defines no partially initialized module binding) Source
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ3018]: the initializer of
firstreachessecond, whose initializer has not completed (v5.2 defines no partially initialized module binding)
During resolution, TPZ3018 reports a direct module initializer read of an uninitialized same-module runtime binding. See module initialization readiness and direct forward reads.
Trigger and repair
During resolution, TPZ3018 reports a direct module initializer read of an uninitialized same-module runtime binding. See module initialization readiness and direct forward reads.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/resolver/validation_init.tpz at
151141d7bb44· 360-385 - compiler/crates/topaz_self_frontend/topaz/resolver/validation_init.tpz at
151141d7bb44· 453-469 - compiler/crates/topaz_self_frontend/topaz/resolver/validation_init.tpz at
151141d7bb44· 784-819 - TPZ3018 at
151141d7bb44
Response
LinkMove the dependency before the initializer. For work intended to happen later, call a function after initialization completes.
Reproduction and verification
LinkRejected program
Linkimport lib
No stdout.
export let first = secondlet second = 1
Expected result
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· 499-507 - compiler/crates/topaz_self_frontend/topaz/resolver/validation_init.tpz at
151141d7bb44· 809-809 - compiler/crates/topaz_self_frontend/topaz/resolver/validation_init.tpz at
151141d7bb44· 360-385 - compiler/crates/topaz_self_frontend/topaz/resolver/validation_init.tpz at
151141d7bb44· 453-469 - compiler/crates/topaz_self_frontend/topaz/resolver/validation_init.tpz at
151141d7bb44· 784-819 - TPZ3018 at
151141d7bb44
Corrected program
Linkimport lib
let second = 1export let first = second
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/validation_init.tpz at
151141d7bb44· 360-385 - compiler/crates/topaz_self_frontend/topaz/resolver/validation_init.tpz at
151141d7bb44· 453-469 - compiler/crates/topaz_self_frontend/topaz/resolver/validation_init.tpz at
151141d7bb44· 784-819 - TPZ3018 at
151141d7bb44