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

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

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

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

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

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

    The program attempts to assign to a binding imported from another module.

    Diagnostic and cause

    Ссылка

    Assignment to imported binding

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

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

    Assigning to a selected import binding produces TPZ3015.

    Действия

    Copy the value into your own let mut binding, or call an operation exported by the producing module.

    Compiler phase: resolve.

    Compiler explanation: The program attempts to assign to a binding imported from another module.

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

    • ⟨value⟩ is an imported binding and cannot be assigned Source
    • ⟨value⟩.⟨value⟩ is an exported binding viewed through a namespace and cannot be assigned Source

    Observed for the candidate in Topaz 5.21.3. Execution

    • error[TPZ3015]: value is an imported binding and cannot be assigned

    The assignment targets a name introduced by a selected import. Importing a binding does not make it mutable in the importing module.

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

    Trigger and repair

    Assigning to a selected import binding produces TPZ3015.

    Response

    Ссылка

    Copy the value into your own let mut binding, or call an operation exported by the producing module.

    Reproduction and verification

    Ссылка

    Rejected program

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

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

    Этап отклонения 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 { value }
    2. let mut localValue = value
    3. localValue = 2
    Ожидаемый выводКод завершения 0
    $ topaz check example.tpz · Целевой продукт 5.21.3
    lib.tpzCorrected programОткрыть песочницу →
    1. export let value = 1
    Ожидаемый результат

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

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

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

    Меню

    Загрузка →