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

    TPZ4601: Duplicate runtime map key

    A map literal or comprehension produced the same key more than once at runtime.

    Diagnostic and cause

    Link

    Duplicate runtime map key

    Family
    topaz
    Phase
    run
    Code
    TPZ4601

    Cause and conditions

    A map comprehension rejects two entries whose evaluated keys have the same canonical key with TPZ4601. The primary location is the map expression. Distinct computed keys construct the map.

    Response

    Ensure that generated entries have distinct keys. If replacing an existing value is intended, perform that update explicitly instead of constructing duplicate entries.

    Source evidence

    Compiler phase: runtime.

    Compiler explanation: A map literal or comprehension produced the same key more than once at runtime.

    Message templates are Pending. The explanation above is not an observed CLI message.

    A map comprehension rejects two entries whose evaluated keys have the same canonical key with TPZ4601. The primary location is the map expression. Distinct computed keys construct the map.

    Rulediagnostics.tpz4601.p5.rule

    Computed map entries require distinct keys

    A map comprehension rejects two entries whose evaluated keys have the same canonical key with TPZ4601. The primary location is the map expression. Distinct computed keys construct the map.

    Source evidence

    Response

    Link

    Ensure that generated entries have distinct keys. If replacing an existing value is intended, perform that update explicitly instead of constructing duplicate entries.

    Reproduction and verification

    Link

    Rejected program

    Link
    example.tpzRejected program
    1. let values = map { for key in (["same", "same"]) => key: 1 }
    Expected outputNonzero exit
    No stdout.
    $ topaz run example.tpz · target product 5.21.3
    Expected result

    Expected result

    Rejection during run. Nonzero exit.

    • TPZ4601 diagnostics-tpz4601 at example.tpz:1:14

    Run the paired runtime product assertions with TOPAZ_BIN set using node docs/topaz-reference/templates/diagnostics-p5-runtime.product.mjs. The shared example observer currently evaluates check diagnostics.

    Source evidence

    Repaired program

    Link
    example.tpzRepaired program
    1. let values = map { for key in (["first", "second"]) => key: 1 }
    Expected outputexit 0
    No stdout.
    $ topaz run example.tpz · target product 5.21.3
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Run the paired runtime product assertions with TOPAZ_BIN set using node docs/topaz-reference/templates/diagnostics-p5-runtime.product.mjs. The shared example observer currently evaluates check diagnostics.

    Source evidence

    Menu

    Download