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. Ненулевой код завершения.
diagnostics-tpz4601 at
example.tpz:1:14
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.