Перейти к содержимому
Топаз6.0 · До релиза
Загрузка →

Поиск в документации

Спецификация 6.0

Выберите результат стрелками и нажмите Enter, чтобы открыть его.

Введите имя API, номер диагностики, правило или тему проекта.

    Диагностика TPZ4601

    A map literal or comprehension produced the same key more than once at runtime.

    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.

    Действия

    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.

    Правилоdiagnostics.tpz4601.p5.rule

    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

    Ссылка
    example.tpzRejected program
    1. let values = map { for key in (["same", "same"]) => key: 1 }
    Ожидаемый выводНенулевой код завершения
    Нет стандартного вывода.
    $ topaz run example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Этап отклонения run. Ненулевой код завершения.

    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

    Ссылка
    example.tpzRepaired program
    1. let values = map { for key in (["first", "second"]) => key: 1 }
    Ожидаемый выводКод завершения 0
    Нет стандартного вывода.
    $ topaz run example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Выполнение завершается. Код завершения 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.

    Меню

    Загрузка →