Reference › Errors
E-VARIANT-AMBIGUOUS
A bare variant reference cannot be resolved to a unique enum.
What it means
Bare variants (.Open) are shorthand that only works where the surrounding declaration fixes the type. If the position has no type context, or more than one enum in scope declares a variant of that name, the compiler has no basis to choose and refuses to guess. Per §14.10 bare variants are legal only at positions where the type is already fixed.
Minimal reproducer
This is the exact source compiled against the linked compiler and verified to produce E-VARIANT-AMBIGUOUS.
<program title="p">
type A:enum = { Open, Shut }
type B:enum = { Open, Closed }
<chosen> = .Open
<p>${@chosen}</p>
</>
How to fix
-
Annotate the declaration.
<chosen>: A = .Openfixes the type at the declaration and the bare variant resolves. -
Qualify the variant.
A.Opennames the enum explicitly. Preferred when two enums genuinely share a variant name and both are in scope.
Related
Specification
Normative text: §14.10, §18.0.3, §34. Spec lives at compiler/SPEC.md .