Skip to content

det translator: a NOT ON SIZE ERROR after a nested unterminated arithmetic statement binds to the outer one #4676

Closed

Description

@squid-protocol

Problem

A conditional arithmetic statement nested in another's ON SIZE ERROR phrase, without its own END- terminator, takes the following NOT ON SIZE ERROR phrase in COBOL (the phrase belongs to the innermost unterminated statement). GnuCOBOL does that; the det translator gives the phrase to the outer statement, so the port runs different statements.

Repro (measured 2026-10-07, GnuCOBOL 3.1.2 -std=ibm; A = 1, B = 3, C = 300, Z0 = 0, R = 12.34, R2 = 1):

           COMPUTE R = A / Z0
             ON SIZE ERROR COMPUTE R2 = A / B * C
             NOT ON SIZE ERROR COMPUTE R2 = A / B * 7
           END-COMPUTE
           DISPLAY 'B1 ' R ' ' R2
           ...more statements, no period

Oracle: B1 01234 00233 and nothing after it (the NOT phrase belongs to the inner COMPUTE; END-COMPUTE closes the innermost COMPUTE, so the rest of the sentence sits inside the outer ON SIZE ERROR). Det port: B1 01234 09900, and it runs the statements after it.

With each nested statement terminated (ON SIZE ERROR COMPUTE ... END-COMPUTE NOT ON SIZE ERROR COMPUTE ... END-COMPUTE END-COMPUTE) both sides agree (pinned by #4655's test_det_size_error.py, B1).

Proposal

In det/stmt.py's scope rules, attach a conditional phrase (ON SIZE ERROR / NOT ON SIZE ERROR, AT END, INVALID KEY, ON OVERFLOW ...) to the innermost unterminated statement that can take it, and pair an END- terminator with the innermost open statement of its verb. Probably rare in real estates (code style terminates nested statements); a test from this repro either way.

Part of #4270.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    legacy-modernization
    priority: low
    on Oct 8, 2026
  2. added
    scope:sweep
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglegacy-modernizationpriority: lowscope:sweep

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions