본문으로 건너뛰기
토파즈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)
    기대 출력0이 아닌 종료 코드
    표준 출력 없음.
    $ topaz run example.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    거절 단계 run. 종료 코드가 0이 아닙니다.

    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}")
    기대 출력0이 아닌 종료 코드
    표준 출력 없음.
    $ topaz run example.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    거절 단계 run. 종료 코드가 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 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.

    메뉴

    다운로드 →