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

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

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

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

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

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

    A namespace member is used in a position that requires a different export kind.

    Diagnostic and cause

    Ссылка

    Namespace member has wrong kind

    Семейство
    topaz
    Этап
    resolve
    Код
    TPZ3013

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

    Using a namespace member that exports a type alias as a value produces TPZ3013. Use that alias in a type annotation.

    Действия

    Use ns.Count in a type annotation or select a value export for the expression.

    Compiler phase: resolve.

    Compiler explanation: A namespace member is used in a position that requires a different export kind.

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

    • namespace members are exported declarations and cannot be keyword-named (⟨value⟩.⟨value⟩) Source
    • ⟨value⟩ is an exported type alias of ⟨value⟩, not a value; use it in type position Source
    • ⟨value⟩ is exported by ⟨value⟩ but is not a type alias Source
    • the head of a qualified type must be a namespace binding; ⟨value⟩ is not one here Source

    Observed for the candidate in Topaz 5.21.3. Execution

    • error[TPZ3013]: Count is an exported type alias of lib, not a value; use it in type position

    The selected member exports a type alias, but the expression requires a value. Nominal constructor names have a separate admitted path.

    Правилоdiagnostics.tpz3013.rule

    Trigger and repair

    Using a namespace member that exports a type alias as a value produces TPZ3013. Use that alias in a type annotation.

    Response

    Ссылка

    Use ns.Count in a type annotation or select a value export for the expression.

    Reproduction and verification

    Ссылка

    Rejected program

    Ссылка
    example.tpzRejected programОткрыть песочницу →
    1. import lib as ns
    2. let value = ns.Count
    Ожидаемый выводНенулевой код завершения
    Нет стандартного вывода.
    $ topaz check example.tpz · Целевой продукт 5.21.3
    lib.tpzRejected programОткрыть песочницу →
    1. export type Count = int
    Ожидаемый результат

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

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

    The expected diagnostic, cause, source location, and accompanying diagnostics are specified below. The verification status records whether this program has been run.

    Corrected program

    Ссылка
    example.tpzCorrected programОткрыть песочницу →
    1. import lib as ns
    2. let value: ns.Count = 1
    Ожидаемый выводКод завершения 0
    $ topaz check example.tpz · Целевой продукт 5.21.3
    lib.tpzCorrected programОткрыть песочницу →
    1. export type Count = int
    Ожидаемый результат

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

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

    This program applies the repair described above. The verification status records whether it has been run.

    Меню

    Загрузка →