Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Diagnostics

    TPZ3018: Initializer reads a later binding

    An imported-module initializer directly reads a later same-module runtime binding.

    Diagnostic and cause

    Link

    Initializer 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 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 first reaches second, 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.

    Rulediagnostics.tpz3018.rule

    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

    Response

    Link

    Move the dependency before the initializer. For work intended to happen later, call a function after initialization completes.

    Reproduction and verification

    Link

    Rejected program

    Link
    example.tpzRejected programOpen in Playground
    1. import lib
    Expected outputNonzero exit
    No stdout.
    $ topaz check example.tpz · target product 5.21.3
    lib.tpzRejected programOpen in Playground
    1. export let first = second
    2. let second = 1
    Expected result

    Expected result

    Rejection during resolve. Nonzero exit.

    • TPZ3018 diagnostic-tpz3018 at lib.tpz:1:20

    The expected diagnostic, cause, source location, and accompanying diagnostics are specified below. The verification status records whether this program has been run.

    Source evidence

    Corrected program

    Link
    example.tpzCorrected programOpen in Playground
    1. import lib
    Expected outputexit 0
    $ topaz check example.tpz · target product 5.21.3
    lib.tpzCorrected programOpen in Playground
    1. let second = 1
    2. export 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

    Menu

    Download