규칙 8.8
8장, 함수와 진입점 테스트
A parameter an author writes must be passed by value, unless it is declared Ref<T>, which names the caller’s place (Rule 8.25); there must be no pointer values.
Whole-value assignment, compound assignment and integer updates of a value parameter must
rebind a mutable local initialized from the input, leaving the caller’s value unchanged.
Only a parameter whose declaration a whole write resolves to gets this local; a shadowing
declaration does not count. Within that body’s scope the local may be written through its
fields or elements. A parameter with no whole write retains its existing read-only place
semantics. Resource handles and the reference-backed arrays of Rule 8.23 are not local-copy values.
The object of a method that changes its object, and a variable of the function around it that a local function writes, are not parameters an author writes: Rules 8.10 and 8.17 govern them, and each is passed by reference.
The one exception an author writes is a kernel function’s parameter of an array with no size, which is the caller’s storage and passed by reference (Rule 8.23).
규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
근거
whether a parameter is a reference is a language decision, which change 0040 took for the parameter declared Ref<T> alone, so a parameter with no such declaration means what TypeScript’s does, a value.
The two references are how the emitted function keeps TypeScript’s own meaning (a method writes the object it was called on, a closure writes the variable it closes over), and no author writes either one.
출처
change 0040 in changes/, which takes the roadmap’s “pointers and reference parameters” for the parameter alone; Function Calls.
검증 방식
테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.
컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.
TS8020 FUNCTION_SHAPE for a parameter shape the surface does not take.
Value rebinding, caller isolation, captures, class bodies, generic/higher-order copies and
entry inputs are pinned by src/compiler/ts/mutable-parameters.test.ts; the immutable GPU
input and distinct local by src/compiler/ts/tint-invalid.test.ts; the packed-package
path by journeys/mutable-parameters/.
커밋 c66579bf에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.
설명하는 절
커밋 c66579bf의 표면 문서에서 이 규칙을 설명하는 절입니다.
적용하는 오류 코드
규칙이 Enforced by 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.
-
TS8020FUNCTION_SHAPE - A function declaration or parameter shape TypeShade does not support (missing name or body, optional/rest/destructured parameter).
함께 보기
소스
커밋 c66579bf의 규칙 원문:
docs/language-design.md:676(설계 문서)reqs/rules/RULE-0808.md(추적 항목)