규칙 6.2
6장, 선언과 리소스 테스트
A storage binding’s access mode is its second type argument: storage<T> is var<storage, read> and storage<T, "read_write"> is var<storage, read_write>.
The only two words the argument takes are "read" and "read_write", spelled as string literal types.
A uniform binding is read-only and has no access mode, so uniform<T> takes one type argument.
A write to a read-only resource must be refused, by the compiler and by the editor.
규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
근거
the access mode is part of the WGSL type, so it belongs in the type, and the host’s bind group layout has to agree with it; the declaration keyword cannot carry it, because a TypeScript const array forbids rebinding the name and permits arr[0] = 1, which is the opposite of what a const storage buffer meant.
출처
var Declarations and Memory Access Mode; surface §7. The two words are WGSL’s own enumerants and already appear on this surface in texture_storage_2d<"r32float", "read_write">, so neither takes a §9.3 row.
검증 방식
테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.
컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.
TS8002for an access word outside the two, and for a second type argument on auniform<T>, raised insrc/compiler/ts/bindings.ts, which recovers the binding asread_writeso that the author’s own write is not a second sentence on the same program;TS8099for the retired{ access }option of the call form, raised in the same file, whose sentence names the type-argument spelling to write;TS8005 CONST_ASSIGNfor a write to a read-only resource, whose sentence names thestorage<T, "read_write">remedy when the target is a storage binding (writableRemedyinsrc/compiler/ts/context.ts), and for an atomic builtin on a read binding, whose sentence names the mode rather than the keyword (src/compiler/ts/lower/atomics.ts). It names no line in the two cases where no line would close the program: when the binding’s declared value type was itself refused and recovered, since the line would be built from a type the compiler could not read (storage<mat2x3<f64>>was answered withstorage<mat2x3, "read_write">, the<f64>dropped), and when the target is no place on either mode, which is why the root’s access is checked after the target is known to be one, for an element (md[0]on anf64matrix) and for a member after every one of that branch’s refusals (src.length, an emulated-double lanedv[0].x, a multi-component swizzlev.xy);- TypeScript’s own codes in the editor, because the ambient library resolves
storage<T>anduniform<T>toReadView<T>andstorage<T, "read_write">toTitself:TS2542on an indexed write (src[0] = 1.),TS2540on a field write (u.scale = 1.),TS2344on an access word outside the two andTS2314on a second type argument to auniform(src/language-service/ambient.test.ts); src/compiler/ts/declare-bind.test.tsfor the access mode each spelling collects, andsrc/compiler/ts/remedy-lines.test.tsfor the lines these sentences name: every refusal that quotes a declaration has that declaration written back into its own program, which must then compile clean and be clean in the editor;- not by the editor in two places, which Appendix B records: an atomic builtin on a read binding and a mutating method on a class-typed read binding are refused by the compiler alone.
커밋 c66579bf에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.
설명하는 절
커밋 c66579bf의 표면 문서에서 이 규칙을 설명하는 절입니다.
적용하는 오류 코드
규칙이 Enforced by 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.
-
TS8002UNKNOWN_TYPE - A type name nothing declares, said once for the file wherever it is written (a parameter, a claim, a type argument,
B<vec3<Foo>>included, an alias, animplementsclause, the base a class or an interface extends, a body no call lowers), a type the library declares for TypeScript alone (Number) where the file declares none of its name, or a type this surface does not take in a position the mapper reads (Rule 2.1). -
TS8005CONST_ASSIGN const나 읽기 전용 리소스처럼 바뀔 수 없는 이름에 값을 대입합니다.-
TS8099UNSUPPORTED UNSUPPORTED(TS8099) is the one deliberate exception to "sequential": it is the catch-all for a diagnostic whose site does not yet deserve its own code, so it stays parked past the sequential range instead of at its head.
함께 보기
소스
커밋 c66579bf의 규칙 원문:
docs/language-design.md:396(설계 문서)reqs/rules/RULE-0602.md(추적 항목)