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

    TPZ5003: Immutable binding mutation

    The program tried to assign through a binding that was not declared mutable.

    Diagnostic and cause

    Link

    Immutable binding mutation

    Family
    topaz
    Phase
    check
    Code
    TPZ5003

    Cause and conditions

    An assignment through an immutable root binding is rejected with TPZ5003 at that root. Declare the root with let mut when subsequent assignment is required.

    Response

    Declare a local root with let mut when it must change. Otherwise, compute a new value and bind it separately.

    Source evidence

    Compiler phase: check/runtime.

    Compiler explanation: The program tried to assign through a binding that was not declared mutable.

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

    Observed for the candidate in Topaz 5.21.3. Execution

    • error[TPZ5003]: value is immutable; declare it with let mut

    An assignment through an immutable root binding is rejected with TPZ5003 at that root. Declare the root with let mut when subsequent assignment is required.

    Rulediagnostics.tpz5003.p5.rule

    Assignment requires a mutable root binding

    An assignment through an immutable root binding is rejected with TPZ5003 at that root. Declare the root with let mut when subsequent assignment is required.

    Source evidence

    Response

    Link

    Declare a local root with let mut when it must change. Otherwise, compute a new value and bind it separately.

    Reproduction and verification

    Link

    Rejected program

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

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5003 diagnostic-tpz5003 at example.tpz:2:1
    Source evidence

    Repaired program

    Link
    example.tpzRepaired program
    1. let mut value = 1
    2. value = 2
    Expected outputexit 0
    $ topaz check example.tpz · target product 5.21.3
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Source evidence

    Menu

    Download