---
title: "Rule 7.6: Expressions and statements in TypeShade"
description: "Rule 7.6 of the TypeShade language design, in Expressions and statements."
url: https://typeshade.dev/reference/rules/7-6/
language: en
---

# Rule 7.6

Chapter 7, Expressions and statements Test

A read of a local before it is assigned on every path must be refused ([`TS8075`](https://typeshade.dev/reference/errors/ts8075/)), by TypeScript’s rule for its TS2454; an argument is a read, as TypeScript reads it, and no call assigns the caller’s local (change 0142); every target starts a local declared with no initializer at the zero of its type. A written `!` on such a local is accepted and changes nothing in the check, which refuses a read of `q` that no assignment comes before (`TS8075`) (change 0130, D3).

The rule text and the parts under it are the compiler's own English, as the design document writes them.

## Rationale

the two targets differed here, WGSL and the CPU reading zero and GLSL ES 3.00 an undefined value, and the editor already refused the read with TypeScript’s TS2454 while the compiler accepted it; the refusal makes the two halves one ([Rule 12.7](https://typeshade.dev/reference/rules/12-7/)), and the zero keeps the targets equal for any read an analysis misses.

## Derives from

change `0043` in `changes/`; change `0111` (D8, replaced by change `0130`, D3); [`var` Declarations](https://gpuweb.github.io/gpuweb/wgsl/#var-decls) (zero-initialization); surface §14 and §70.

## How it is verified

Checked by a test. A test, a gate script or a CI workflow names this rule, and the traceability check fails when a file listed below stops naming it.

Where the rule says the compiler enforces it:

`TS8075 UNASSIGNED_READ` in `src/compiler/ts/definite.ts`; the zero initializer of `localVar` in `src/core/backends/glsl/backend.ts`; pinned by `src/compiler/ts/definite-assignment.test.ts`, which holds [`TS8075`](https://typeshade.dev/reference/errors/ts8075/) to TypeScript’s TS2454 reads, and `src/compiler/ts/attribute-types.test.ts`, which refuses a read of a local before it is assigned.

The files that verify it at commit af54ddad5, each at the first line that names the rule:

- [`src/compiler/ts/attribute-types.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/attribute-types.test.ts#L1)
- [`src/compiler/ts/definite-assignment.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/definite-assignment.test.ts#L1)
- [`src/compiler/ts/definite.ts:77`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/definite.ts#L77)
- [`src/compiler/ts/host-kernel-out.test.ts:3`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-kernel-out.test.ts#L3)
- [`src/core/backends/glsl/backend.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/backends/glsl/backend.ts#L1)

## Explained in

The sections of the surface document that explain this rule, at commit af54ddad5:

- [§7 Diagnostics (required)](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#7-diagnostics-required)
- [§14 TypeScript shapes the parser already had](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#14-typescript-shapes-the-parser-already-had)
- [§70 Objects, passed as JavaScript passes them](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#70-objects-passed-as-javascript-passes-them)
- [§76 Optional values: `T | undefined`, `T | null` and three states](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#76-optional-values-t--undefined-t--null-and-three-states)

## Error codes that enforce it

The diagnostic codes the rule names under Enforced by, or whose registry text names the rule:

**[`TS8075`](https://typeshade.dev/reference/errors/ts8075/) `UNASSIGNED_READ`**

A read of a local before it is assigned on every path (Rule 7.6), by TypeScript's rule for its TS2454. An argument is a read, and no call assigns the caller's local. The editor shows this code where TypeScript reports TS2454.

## See also

- [Rule 7.5](https://typeshade.dev/reference/rules/7-5/) Test
- [Rule 7.7](https://typeshade.dev/reference/rules/7-7/) Test
- [Rule 12.7](https://typeshade.dev/reference/rules/12-7/)
- [Design rules](https://typeshade.dev/reference/rules/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

The rule at commit af54ddad5:

- [`docs/language-design.md:702`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L702) (the design document)
- [`reqs/rules/RULE-0706.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-0706.md) (its traceability item)
