# inconsistent-field-order

Require nominal literal fields in declaration order

Nominal literals written in a different order from their declaration are harder to compare with their type.
Instead, you SHOULD initialize supplied fields in declaration order.

Spreads begin a new ordering region because moving an initializer across a spread can change behavior.

- Category: style
- Level: warning
- Fix: none
- Scope: module

## Reported

```ds title="main.ds"
struct Point {
    x: int32;
    y: int32;
}

const point = Point { y: 2, x: 1 };
```

## Accepted

```ds title="main.ds"
struct Point {
    x: int32;
    y: int32;
}

const point = Point { x: 1, y: 2 };
```

## Prior art

- [Clippy · inconsistent_struct_constructor](https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_struct_constructor)

[language/linter/src/rules/style/inconsistent_field_order.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/inconsistent_field_order.rs#L8)
