Renderingen-US

Experimental through version 1. Version 0 was alpha. This is the first language release: the interface is relatively stable, not frozen. Nothing is promised stable until version 2.

elige duplicate case value

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

A switch case value may be claimed once; a repeat is a duplicate literal.

Syntax: switch d { case 1 { } case 1 { } default { } }

Category#

control-flow

Examples#

radix/corpus/elige/duplicate-case-reject.fab (canonical · reject)#

A switch case value may be claimed once; a repeat is a duplicate literal.

# =============================================================================
# switch duplicate case value — one value, one arm
# =============================================================================
# A switch arm answers for its case value, so a value can be claimed once.
# This switch claims 1 twice, and the check reports SEM042 with the issue
# duplicate_literal instead of silently keeping the first arm.

fn classify(int d) → string {
    switch d {
        case 1 {
            return "one"
        }
        case 1 {
            return "again"
        }
        default {
            return "other"
        }
    }
}

main {
    print classify(1)
}

Expected: compilation rejects this example.