규칙 7.6
7장, 표현식과 문 테스트
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.
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 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), and the zero keeps the targets equal for any read an analysis misses.
출처
change 0043 in changes/; change 0111 (D8, replaced by change 0130, D3); var Declarations (zero-initialization); surface §14 and §70.
검증 방식
테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.
컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.
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 to TypeScript’s TS2454 reads, and src/compiler/ts/attribute-types.test.ts, which refuses a read of a local before it is assigned.
커밋 af54ddad5에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.
설명하는 절
커밋 af54ddad5의 언어 문서에서 이 규칙을 설명하는 절입니다.
적용하는 오류 코드
규칙이 Enforced by 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.
-
TS8075UNASSIGNED_READ - 모든 경로에서 대입되기 전에 지역 변수를 읽습니다(규칙 7.6). TypeScript의 TS2454 규칙을 따릅니다. 인자도 읽기이며, 어떤 호출도 호출자의 지역 변수에 대입하지 않습니다. TypeScript가 TS2454를 보고하는 자리에서 편집기는 이 코드를 보여 줍니다.
함께 보기
소스
커밋 af54ddad5의 규칙 원문:
docs/language-design.md:702(설계 문서)reqs/rules/RULE-0706.md(추적 항목)