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

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

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

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

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

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

    Nested Topaz calls exceeded the shared call-depth limit.

    Diagnostic and cause

    Ссылка

    Recursion limit exceeded

    Семейство
    topaz
    Этап
    run
    Код
    TPZ5009

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

    Named program functions, lambdas, user callbacks, protocol methods, and receiver methods each count as one active call. Standard functions do not count. A user callback invoked by a standard function counts. A defer block does not add a call. A concurrent arm inherits the depth of the call that opened its group. Entering a counted call while 1000 calls are active produces TPZ5009 at the rejected call. An implementation must not exhaust its stack while fewer than 1000 counted calls are active.

    Действия

    Check the base case and progress toward it. Rewrite deep recursion as a loop when the input can require many calls.

    Compiler phase: runtime.

    Compiler explanation: Nested Topaz calls exceeded the shared call-depth limit.

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

    The program attempts to enter a counted call while 1000 counted calls are active.

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

    Counted calls and the runtime depth limit

    Named program functions, lambdas, user callbacks, protocol methods, and receiver methods each count as one active call. Standard functions do not count. A user callback invoked by a standard function counts. A defer block does not add a call. A concurrent arm inherits the depth of the call that opened its group. Entering a counted call while 1000 calls are active produces TPZ5009 at the rejected call. An implementation must not exhaust its stack while fewer than 1000 counted calls are active.

    Причина

    The same program reaches the same call-depth diagnostic on every target. Host stack size must not cause an earlier failure.

    Response

    Ссылка

    Check the base case and progress toward it. Rewrite deep recursion as a loop when the input can require many calls.

    Reproduction and verification

    Ссылка

    Rejected program

    Ссылка
    example.tpzRejected program
    1. function descend(depth: int) -> int {
    2. if (depth == 0) {
    3. 0
    4. } else {
    5. descend(depth - 1)
    6. }
    7. }
    8. let result = descend(1001)
    Ожидаемый выводНенулевой код завершения
    Нет стандартного вывода.
    $ topaz run example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

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

    Run the named-function and lambda runtime examples with TOPAZ_BIN set using node docs/topaz-reference/templates/diagnostics-p5-runtime.product.mjs.

    Repaired program

    Ссылка
    example.tpzRepaired program
    1. function descend(depth: int) -> int {
    2. if (depth == 0) {
    3. 0
    4. } else {
    5. descend(depth - 1)
    6. }
    7. }
    8. let result = descend(10)
    Ожидаемый выводКод завершения 0
    Нет стандартного вывода.
    $ topaz run example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

    Выполнение завершается. Код завершения 0.

    Run the named-function and lambda runtime examples with TOPAZ_BIN set using node docs/topaz-reference/templates/diagnostics-p5-runtime.product.mjs.

    A recursive lambda reaches the same call limit

    Ссылка
    example.tpzA recursive lambda reaches the same call limit
    1. import std.io
    2. let mut descend: (int) -> int = (depth) => 0
    3. descend = (depth) => {
    4. if (depth == 0) {
    5. 0
    6. } else {
    7. descend(depth - 1)
    8. }
    9. }
    10. let result = descend(1001)
    11. io.writeLine("{result}")
    Ожидаемый выводНенулевой код завершения
    Нет стандартного вывода.
    $ topaz run example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

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

    Run the named-function and lambda runtime examples with TOPAZ_BIN set using node docs/topaz-reference/templates/diagnostics-p5-runtime.product.mjs.

    A recursive lambda finishes below the call limit

    Ссылка
    example.tpzA recursive lambda finishes below the call limit
    1. import std.io
    2. let mut descend: (int) -> int = (depth) => 0
    3. descend = (depth) => {
    4. if (depth == 0) {
    5. 0
    6. } else {
    7. descend(depth - 1)
    8. }
    9. }
    10. let result = descend(10)
    11. io.writeLine("{result}")
    Ожидаемый выводКод завершения 0
    0
    
    $ topaz run example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

    Выполнение завершается. Код завершения 0.

    Ожидаемый стандартный вывод
    1. 0

    Run the named-function and lambda runtime examples with TOPAZ_BIN set using node docs/topaz-reference/templates/diagnostics-p5-runtime.product.mjs.

    Меню

    Загрузка →