---
title: "Semantic restrictions"
description: "What the compiler checks after parsing: closed types, complete records, effect-free functions, action snapshots and sends, view roots, scrollers and the route table."
modificationDate: "2026-11-30"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Semantic restrictions

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/reference/contract-grammar/semantic-restrictions: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

Syntax is only the first layer. In particular:

- Types are closed; unknown/unresolved types, cycles, and invalid property values
  are refused. `none` and `[]` need enough context to infer their contained type,
  or a state's declared one (`state ids: string[] = []`).
- Record construction requires all fields once; copying requires a matching base.
  Shapes are finite and nonrecursive. Equality compares values structurally.
- Function bodies are effect-free, nonrecursive expressions (they may read
  `performanceNow()`); an app's function may shadow a roster name (and is then
  called `name(x)`, as it is declared) but not take a declared shape's constructor name.
- Action reads see the starting snapshot. Writes land together. Locals are
  immutable and cannot shadow visible names or escape their block.
- A child may own ordinary state, derives and actions, and, at bounded uses,
  resources, mutations and tasks (`type-child-resource`). Each instance owns its
  work; its task runs in that instance's frame until destruction. Hidden instances
  stay alive, so a task that should stop while hidden needs a `when` gate.
  An action writes only its own admitted slots.
- A `then` handler takes no parameters and must not send its own mutation.
- A state's initializer reads only props, injects and the states above it; a
  resource, derive, mutation, action or later state it names is
  `type-initializer-scope` (LLP 1088 D4).
- `persist` (LLP 1116 D5) keeps a root state across launches under its name: a
  stored value of its type replaces the initializer's before the first frame,
  and after each commit that stands the store holds the state's value. Only a
  number, string or bool, or an option or list of one, at most 16 KB as JSON;
  a record, a list of records or a state holding an action is
  `type-persist-type` (keep app data in a source), a child's state
  `type-persist-child`, a derive `syntax-persist-derive`.
  `persist window` uses the same types and limit and restores the value in the
  window that saved it. A fresh window uses the initializer.
- An action sends one mutation at most once on any path: a second send forgets
  the first's reply (LLP 1016 D5), so it is `analyze-send-twice` — unless the
  mutation is `queue`, whose sends each wait their turn (LLP 1092 D6), or
  `parallel`, whose sends each land (LLP 1161.000 D2). Exclusive
  `if`/`match` arms, and sequential `if`s testing one unchanged name against
  different literals, are separate paths (LLP 1088 D8). A `match` binder and an
  outer name it shadows are different values; their tests do not prove separate
  paths. The walk reads the root's actions with every call expanded, where a caller
  and its callees are one commit.
- A read of a state or mutation slot that the action assigned earlier on the
  same path sees the starting value, since writes land when the action ends: it
  is the warning `analyze-read-after-assign` (LLP 1116.003 D6; LLP 1035.005.002
  C2), in the action's own body or behind a call (the action's body, or another
  call, assigned it; LLP 1089 D3), one rule at one severity. The message names
  the repair: bind the value, `let next = …`, assign `next`, read or pass `next`;
  a `let` bound before the write keeps the old value. Not named: a read on a
  path exclusive with the assignment's, a condition the assignment's path
  decides (`if phase == 1` … `phase = 2`, then `if phase == 2`), and a field a
  record copy left unchanged (`s = S(s, f=…)`, then `s.g`). A derive, a resource
  and `pending(m)` read settled values. In 1,029 bake-off builds the body's read
  was met in 86 and the call's in 2, which is why the call's is no longer a
  refusal. `pending`/`failed` operate on declarations, not arbitrary values.
- An action that both sends a newest-wins mutation and assigns it on one path, in
  either order and through calls, is warned of (`analyze-send-assigned`, LLP
  1035.005.002 C1): a send is asked when the action runs; once the writes land,
  a request still in flight for a mutation the action assigned is forgotten and
  its reply dropped, and the slot keeps the assigned value (LLP 1016 D5). The
  message names the three intents' spellings; a `queue` or `parallel`
  mutation's assignment forgets no request (LLP 1092 D4, LLP 1161.000 D4) and
  is not named. No bake-off build wrote
  the combination; Weird Castle's logout means it.
- View roots cannot be conditional/repeated regions. Tags, attributes, and
  children must fit their lowering rules. Class application is not a CSS cascade.
- Scrollers need bounds; virtualized lists have specific axis, template, and
  nesting requirements. The bake additionally checks measured geometry.
- One root route table supplies implicit router state and types. `path` needs a
  literal known route name and the right number of parameter values.
- Source imports stay inside the app directory. A `.contract` import does not
  import arbitrary executable code.
- Timer intervals, literal-only styles, keyframe constants, font files,
  localization tables, native schemas, and optional capabilities have separate
  checks. Runtime/host coverage is not implied by successful parsing.

The [compiler corpus](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/corpus) and
[compiler integration tests](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/cli/tests/it) contain executable accept
and refusal examples. Use their diagnostic ids to find the rule that rejected a
program rather than expanding this grammar speculatively.
