Skip to content

TP0216

Error: ambiguous enum variant; qualify it

  • '<v>' is ambiguous: it is a variant of <E1> and <E2>, with help qualify it, e.g. '<E1>.<v>'

From the golden case tests/cases/m7/tp0216_ambiguous.tpn:

tp0216_ambiguous.tpn
enum Health:
Ok
Down
enum Result:
Ok
Failed(reason: str)
let a = Ok
let b: Health = Ok
let c = Health.Ok
let d = Result.Ok
let e = Failed("x")
def check(h: Health) -> str:
match h:
Ok: return "fine"
Down: return "down"

The compiler reports:

tp0216_ambiguous.tpn:9:9: error TP0216: 'Ok' is ambiguous: it is a variant of Health and Result
help: qualify it, e.g. 'Health.Ok'
tp0216_ambiguous.tpn:10:17: error TP0216: 'Ok' is ambiguous: it is a variant of Health and Result
help: qualify it, e.g. 'Health.Ok'

The specification lists every code.