> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sifr.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# SIFR-PROTO-0004: Hashable or comparable protocol is required.

> Hashable or comparable protocol is required.

`SIFR-PROTO-0004` belongs to the **Protocols** diagnostic family. It means: hashable or comparable protocol is required.

## Why It Happens

A value does not satisfy the structural protocol required by the operation, such as iteration, context management, or indexing.

<Info>
  Use `sifr --explain SIFR-PROTO-0004` locally to see the renderer's exact message template and any machine-applicable suggestions for the compiler version you are running.
</Info>

## Erroneous Code

```python theme={null}
for item in NotIterable():
    pass
```

## How To Fix It

Implement the required protocol shape, or pass a value that already satisfies the iterator, context-manager, hashable, or comparable requirement.

## Fixed Code

```python theme={null}
class Items:
    def __iter__(self) -> Iterator[int]:
        return iter([1, 2, 3])

for item in Items():
    pass
```

## Details

| Field                  | Value                                                 |
| ---------------------- | ----------------------------------------------------- |
| Code                   | `SIFR-PROTO-0004`                                     |
| Family                 | `PROTO`                                               |
| Severity               | Error                                                 |
| Stability              | stable                                                |
| Owner                  | `sifr_lowering::lower::expressions`                   |
| Representative fixture | `crates/sifr/tests/e2e/fail/unhashable_dict_key.sifr` |

See the [Error Codes index](/diagnostics/error-codes) for the complete catalog.
