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
Related#
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.