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

    TPZ2010: Import after non-import item

    An import appears after a top-level item that ends the import prologue.

    Diagnostic and cause

    Link

    Import after non-import item

    Family
    topaz
    Phase
    parse
    Code
    TPZ2010

    Cause and conditions

    Every top-level import precedes every non-import top-level item.

    Response

    Move all imports before the module's declarations and free statements.

    Source evidence

    Compiler phase: parse.

    Compiler explanation: An import appears after a top-level item that ends the import prologue.

    Message templates. The marker ⟨value⟩ stands for text computed for the reported program.

    • imports form a prologue: every import precedes all other top-level items Source

    Observed for the candidate in Topaz 5.21.3. Execution

    • error[TPZ2010]: imports form a prologue: every import precedes all other top-level items

    An import follows a non-import top-level item. That item ended the import prologue.

    Rulediagnostics.tpz2010.rule

    Trigger and repair

    Every top-level import precedes every non-import top-level item.

    Source evidence

    Response

    Link

    Move all imports before the module's declarations and free statements.

    Reproduction and verification

    Link

    Rejected program

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

    Expected result

    Rejection during parse. Nonzero exit.

    • TPZ2010 diagnostic-tpz2010 at example.tpz:2:1

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

    Menu

    Download