# Flags enums

A [flags] enum represents combinable named bits. Test membership with .Has rather than treating a combination as one match case.

Last updated: 2026-09-09

Package: language | Status: experimental

Tags: Has, [flags], cpu, enum, flags, language, logic, yeho

Use flags for independent capabilities or state bits that can be combined.

```yh
[flags] enum Name { A, B, C }
value.Has(Name.Member)
```


## Declare named access flags

Store and compare one named document capability. Enum bitwise combinations and native .Has lowering are not qualified by this example.

Verification: executed

```yh
[flags]
enum Access { Read, Write }
Access granted = Access.Read
if granted == Access.Read { Console.Log("Read access") }

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.language__flags_enums"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

```

Expected output:

```text
Read access
```

Executed backend: cpu-oracle

Observed output:

```text
Read access
```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/language--flags-enums/complete --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


Flags enums cannot have payload members.

The parser accepts .Has, but the current CPU oracle build does not lower it. Enum bitwise combinations are also rejected. Use integer masks for executable combinations, or compare one named enum value directly.

Source: yeho/parser_core.cpp parseTopLevelEnum; language-core.md §5.6

AI training permission: https://demonhunterlabs.com/ai-use
