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

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

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

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

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

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

    The program tried to assign through a binding that was not declared mutable.

    Diagnostic and cause

    Ссылка

    Immutable binding mutation

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

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

    An assignment through an immutable root binding is rejected with TPZ5003 at that root. Declare the root with let mut when subsequent assignment is required.

    Действия

    Declare a local root with let mut when it must change. Otherwise, compute a new value and bind it separately.

    Compiler phase: check/runtime.

    Compiler explanation: The program tried to assign through a binding that was not declared mutable.

    Message templates are Pending. The explanation above is not an observed CLI message.

    Observed for the candidate in Topaz 5.21.3. Execution

    • error[TPZ5003]: value is immutable; declare it with let mut

    An assignment through an immutable root binding is rejected with TPZ5003 at that root. Declare the root with let mut when subsequent assignment is required.

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

    Assignment requires a mutable root binding

    An assignment through an immutable root binding is rejected with TPZ5003 at that root. Declare the root with let mut when subsequent assignment is required.

    Response

    Ссылка

    Declare a local root with let mut when it must change. Otherwise, compute a new value and bind it separately.

    Reproduction and verification

    Ссылка

    Rejected program

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

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

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

    Repaired program

    Ссылка
    example.tpzRepaired program
    1. let mut value = 1
    2. value = 2
    Ожидаемый выводКод завершения 0
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

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

    Меню

    Загрузка →