SD0107
On this page

SD0107

Core code

assignment to an immutable 'let' binding

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

In the front end

A "use typeshade" file never reaches this check with the same mistake: the front end refuses it first, under its own code. This program, compiled at build time, gets:

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

TS8005 error, line 6: Cannot assign to "g" — it is declared with const.

How to fix it

The registry's hint: declare the binding with Var() instead of Let() to mutate it

See also

TS8005 CONST_ASSIGN
An assignment to a name or a place that cannot change: a const number or vector, a component of a const vector or matrix, a readonly field or static, or a storage binding that readonly or "read" promises is never written. A write to a field or an element of a const object is not one of these, because the const holds the object and the object stays writable, as in JavaScript (Rule 6.10).

Source

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

Edit this page Report a problem