TS8075
이 페이지에서

TS8075

프런트엔드 코드 UNASSIGNED_READ

모든 경로에서 대입되기 전에 지역 변수를 읽습니다(규칙 7.6). TypeScript의 TS2454 규칙을 따릅니다. 인자도 읽기이며, 어떤 호출도 호출자의 지역 변수에 대입하지 않습니다. TypeScript가 TS2454를 보고하는 자리에서 편집기는 이 코드를 보여 줍니다.

레지스트리에는 이 상수에 대한 문서 주석이 없습니다. 그래서 위 설명은 컴파일러가 이 코드와 함께 내는 메시지를 보고 이 사이트가 쓴 것입니다.

레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

예제

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

빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.

TS8075 error, 9행: "g" is read here before it is assigned on every path. Assign it before this read, or declare it with a value (Rule 7.6).

TS8075 error, 9행: "g" is read here before it is assigned on every path. Assign it before this read, or declare it with a value (Rule 7.6).

TS8075 error, 9행: "g" is read here before it is assigned on every path. Assign it before this read, or declare it with a value (Rule 7.6).

고치는 법

같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.

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

이 코드가 적용하는 규칙

규칙 7.6 테스트
A read of a local before it is assigned on every path must be refused (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.
규칙 12.7 테스트
The language service and the compiler must name one vocabulary: the ambient library’s declarations are derived from the compiler’s own tables and never retyped, a builtin’s overloads from Tint’s core.def through the TypeShade overlay, and a program the compiler accepts must draw no error in the editor or in tshc check.

함께 보기

소스

커밋 af54ddad5에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.

이 페이지 편집 문제 보고