Diagnostic and cause
링크Duplicate runtime map key
- 계열
- topaz
- 단계
- run
- 코드
TPZ4601
원인과 조건
A map comprehension rejects two entries whose evaluated keys have the same canonical key with TPZ4601. The primary location is the map expression. Distinct computed keys construct the map.
관련 규칙 · Computed map entries require distinct keys →대응
Ensure that generated entries have distinct keys. If replacing an existing value is intended, perform that update explicitly instead of constructing duplicate entries.
Compiler phase: runtime.
Compiler explanation: A map literal or comprehension produced the same key more than once at runtime.
Message templates are Pending. The explanation above is not an observed CLI message.
A map comprehension rejects two entries whose evaluated keys have the same canonical key with TPZ4601. The primary location is the map expression. Distinct computed keys construct the map.
Computed map entries require distinct keys
A map comprehension rejects two entries whose evaluated keys have the same canonical key with TPZ4601. The primary location is the map expression. Distinct computed keys construct the map.
Response
링크Ensure that generated entries have distinct keys. If replacing an existing value is intended, perform that update explicitly instead of constructing duplicate entries.
Reproduction and verification
링크Rejected program
링크let values = map { for key in (["same", "same"]) => key: 1 }
표준 출력 없음.기대 결과
Run the paired runtime product assertions with TOPAZ_BIN set using node docs/topaz-reference/templates/diagnostics-p5-runtime.product.mjs. The shared example observer currently evaluates check diagnostics.
Repaired program
링크let values = map { for key in (["first", "second"]) => key: 1 }
표준 출력 없음.기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
Run the paired runtime product assertions with TOPAZ_BIN set using node docs/topaz-reference/templates/diagnostics-p5-runtime.product.mjs. The shared example observer currently evaluates check diagnostics.