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

    TPZ5710: Or-pattern alternatives bind different names

    Every alternative of a binding or-pattern must bind the same set of names.

    Diagnostic and cause

    Link

    Or-pattern alternatives bind different names

    Family
    topaz
    Phase
    check
    Code
    TPZ5710

    Cause and conditions

    During checking, TPZ5710 reports different name sets in alternatives of an or-pattern. The or-pattern binding rule defines the binding requirement.

    Response

    Use Some(_) | None() when the arm does not need a binding. Otherwise bind the same names in every alternative or write separate arms.

    Source evidence

    Compiler phase: check.

    Compiler explanation: Every alternative of a binding or-pattern must bind the same set of names.

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

    • or-pattern alternatives must bind the same names — ⟨value⟩ is bound in one alternative but not another Source

    During checking, TPZ5710 reports different name sets in alternatives of an or-pattern. The or-pattern binding rule defines the binding requirement.

    Rulediagnostics.tpz5710.p5.rule

    Different names in or-pattern alternatives

    During checking, TPZ5710 reports different name sets in alternatives of an or-pattern. The or-pattern binding rule defines the binding requirement.

    Source evidence

    Response

    Link

    Use Some(_) | None() when the arm does not need a binding. Otherwise bind the same names in every alternative or write separate arms.

    Reproduction and verification

    Link

    Rejected program

    Link
    example.tpzRejected programOpen in Playground
    1. function read(value: Option<int>) -> int {
    2. match (value) {
    3. case Some(item) | None() => 0
    4. }
    5. }
    Expected outputNonzero exit
    No stdout.
    $ topaz check example.tpz · target product 5.21.3
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5710 or-pattern-alternatives-bind-different-name-sets at example.tpz:3:10
    Source evidence

    Repaired program

    Link
    example.tpzRepaired program
    1. function read(value: Option<int>) -> int {
    2. match (value) {
    3. case Some(_) | None() => 0
    4. }
    5. }
    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