The one value of feature is a selection type for choosing exactly one primitive value.

It provides a way to constrain a set of primitive values acceptable in some context. It is similar to the One Of feature, but it uses primitive values directly instead of identities that map to primitives. The shared selection type rules are defined in Selection Types.

Full syntax:

BitWidth is one value of (
	16
	32
	64
)

Name is one value of (
	"bob"
	"joe"
	"sue"
)

foo(w is BitWidth)
(
	console.log(w)
)

bar(n is Name)
(
	console.log(n)
)

start
(
	// Good
	foo(16)
	foo(BitWidth.32)
	bar("bob")
	bar(Name."bob")
	
	// Bad
	foo(33)
	bar("alice")
)

At the time of this writing, each component in the one value of definition must all resolve to the same underlying primitive type. Any primitive type listed in 03-Numbers is allowed.

The underlying type is inferred in all cases and currently cannot be specified explicitly by the author.

Numeric literals begin provisionally unless another type is forced by context. Numeric compatibility and conversion follow the rules described in 04-Provisional-Numbers.

The one value of blocks may also reference scope values, provided that those values are constant resolvable and conform to the rest of the type provided by the system.

abc = 1
xyz = 2

Onevo is one value of (
	abc
	xyz
)

foo(v is Ovo)
(
	console.log(v)
)

start
(
	// Good
	foo(1)
	foo(2)
	foo(abc)
	
	// Bad
	foo(3)
)

Spreads

one value of supports spreading other one value of declarations.

SmallWidth is one value of (
	16
	32
)

BitWidth is one value of (
	...SmallWidth
	64
)

It may also spread a fixed constant array.

span = [2, 3, 4]

Nums is one value of (
	1
	...span
	5
)

Duplicate values are not allowed in a one value of selection.

Parsing

The member-style value access syntax is part of the parsed language.

BitWidth.32
Name."bob"

These forms are not merely editor display sugar.