TS8018
On this page

TS8018

Front-end code ASSIGN_TARGET

An assignment or ++/-- target that is not a writable place, such as a temporary. An unknown name is UNKNOWN_NAME, and a write to a known immutable binding is CONST_ASSIGN.

The registry has no documentation comment for this constant, so the line above is written by this site from the messages the compiler raises it with.

The registry text and every compiler message on these pages are the compiler's own English.

Example

example.shade.ts
"use typeshade"
@fragment
export function main(uv: location<0, vec2>): vec4 {
vec2(uv).x = 1.
return vec4(uv, 0., 1.)
}

Compiled at build time against the pinned compiler, this program gets:

TS8018 error, line 5: Assignment target must be a name, or a field, component or element of one.

How to fix it

The same program, corrected. It compiles with no diagnostic.

example.shade.ts
"use typeshade"
@fragment
export function main(uv: location<0, vec2>): vec4 {
let st = uv
st.x = 1.
return vec4(st, 0., 1.)
}

The rules this enforces

Rule 8.11 Test
A get or set accessor is a function of the module, Owner_get_x or Owner_set_x, which takes its object as a method does (Rules 8.10 and 8.28); a read of o.x must call the getter, and an assignment, a compound assignment, ++ and -- must call the setter with the new value, the compound forms reading the old one through the getter.
Rule 8.17 Test
A local function (a const that holds an arrow function or a function expression, or a function declaration, written inside a function’s body) is a function of the module named after the body that declares it (surface §14), and it may read and write the variables of the functions around it, as a TypeScript closure does.

See also

Source

Where the compiler raises this code at commit af54ddad5, one line per file:

Edit this page Report a problem