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

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

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

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

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

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

    Inference reached a value whose type stays ambiguous without more context.

    Diagnostic and cause

    Ссылка

    Type could not be inferred

    Семейство
    topaz
    Этап
    check
    Код
    TPZ5020

    Причина и условия

    A bare empty array binding needs a contextual element type. An Array<T> annotation supplies that context.

    Действия

    Add a type annotation at the binding, parameter, or surrounding expression so inference can choose the required type.

    Compiler phase: check.

    Compiler explanation: Inference reached a value whose type stays ambiguous without more context.

    Message templates. The marker ⟨value⟩ stands for text computed for the reported program.

    • this expression needs a contextual type (§22.1): annotate the binding or surrounding expectation Source
    • map {} needs a contextual type (§6): annotate the binding or the expected key/value types Source

    Observed for the candidate in Topaz 5.21.3. Execution

    • error[TPZ5020]: [] needs a contextual type (§22.1): annotate the binding or the expected element type

    A bare empty array binding needs a contextual element type. An Array<T> annotation supplies that context.

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

    Type could not be inferred

    A bare empty array binding needs a contextual element type. An Array<T> annotation supplies that context.

    Response

    Ссылка

    Add a type annotation at the binding, parameter, or surrounding expression so inference can choose the required type.

    Reproduction and verification

    Ссылка

    Rejected program

    Ссылка
    example.tpzRejected programОткрыть песочницу →
    1. let values = []
    Ожидаемый выводНенулевой код завершения
    Нет стандартного вывода.
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

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

    • TPZ5020 →

      diagnostics-empty-array-needs-context at example.tpz:1:14

    Repaired program

    Ссылка
    example.tpzRepaired program
    1. let values: Array<int> = []
    Ожидаемый выводКод завершения 0
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

    Проверка принимает программу. Код завершения 0.

    Меню

    Загрузка →