Skip to content

COBOL/PL/I engine: a paragraph ends at its last line-leading GOBACK/EXIT/RETURN, even a conditional one, so the code after it loses its PERFORM/CALL edges (root cause of #4283) #4301

Closed

Description

@squid-protocol

Problem

detector._slice_by_labels (Mode A, used for COBOL and PL/I) cuts each unit at the last match of assembly_returns (\b(?:...|RETURN|...|GOBACK|EXIT)\b) that starts a line. That is right for assembler, wrong for COBOL/PL/I, where these words are often conditional or not terminators at all. Everything after the cut is outside every unit: its calls_out_to, transfers_to, LOC and complexity are lost. Three shapes in the crucible:

  1. Conditional terminator -- IF ... GOBACK END-IF then more statements; a CICS RETURN TRANSID(...) on its own continuation line inside an IF; PL/I ELSE RETURN;.
  2. Paragraph name that starts with the word -- RETURN-TO-PREV-SCREEN.: \bRETURN\b matches at the header itself (- is a word boundary), so the unit is cut to its header line.
  3. EXIT PERFORM / EXIT PARAGRAPH / EXIT SECTION mid-body.

Evidence (language-crucible v1.7.0, main 737cab8 and #4290 head, identical)

  • Shape 1, CBSA (keyed corpus), 12 files, 553 code lines and 39 PERFORM edges outside any unit:
    • UPDCUST.cbl A010 (138) ends at the GOBACK at 194; PERFORM UPDATE-CUSTOMER-VSAM (200) and PERFORM GET-ME-OUT-OF-HERE (205) are lost. This is COBOL engine: UPDCUST records no PERFORM edges #4283. The file has no PERFORM edges at all.
    • CRECUST.cbl P010 ends at the GOBACK at 411; 9 PERFORMs (422-476, incl. CREDIT-CHECK and WRITE-CUSTOMER-VSAM) are lost.
    • BANKDATA.cbl A010 ends at 406; 165 code lines and 8 PERFORMs are lost.
    • BNK1CAC/CCA/CCS/CRA/DAC/DCS/TFN/UAC.cbl and BNKMENU.cbl: A010 ends at the RETURN TRANSID('Oxxx') continuation line; POPULATE-TIME-DATE / ABEND-THIS-TASK / RESTORE-TERM-DEF are lost.
    • PL/I: DSF R0010422-R0010425.pli KONTROLL_AV_INPUT ends at ELSE RETURN; (R0010422:315); CALL SEND_MAP at :322 is lost.
  • Shape 2, CardDemo (keyed corpus), 11 files: RETURN-TO-PREV-SCREEN / RETURN-TO-SIGNON-SCREEN / RETURN-TO-CICS (e.g. COBIL00C.cbl:273, COADM01C.cbl:160) have loc 1. The body (MOVE, EXEC CICS XCTL) is outside the unit.
  • Shape 3: gnucobol/CBL_OC_DUMP.cob:239 exit perform cuts MAIN00.
  • Minimal repro (REPRO1.cbl (below)): MAIN-PARA has loc 3 and calls_out_to = [], against 4 real callees. RETURN-TO-MENU has loc 1. LOOP-PARA is cut at EXIT PERFORM.

Why the answer key did not catch it

The key scores unit names and lines, never spans or edges, so the units are "correct" while their bodies are dropped.

Acceptance criteria

  • COBOL and PL/I units run to the next unit header (or END PROGRAM / END proc), not to the last terminator keyword
  • Or, if a terminator cut is kept for assembler: COBOL and PL/I opt out through _NON_TERMINATING_KEYWORDS_BY_LANG, and a match inside a hyphenated name is rejected at line start too
  • Repro and the CBSA/CardDemo/DSF files above get their edges; COBOL engine: UPDCUST records no PERFORM edges #4283 closes
  • A span/edge check in the answer-key score, so this class is visible

Found during: crucible mainframe count audit (2026-10-04)

Reproducer

REPRO1.cbl

       IDENTIFICATION DIVISION.
       PROGRAM-ID. REPRO1.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  WS-FLAG                PIC X VALUE 'N'.
       01  WS-I                   PIC 9(4) COMP VALUE 0.
       PROCEDURE DIVISION.
           PERFORM ENTRY-TARGET
           PERFORM MAIN-PARA
           GOBACK.
       MAIN-PARA.
           IF WS-FLAG = 'Y'
              GOBACK
           END-IF
           PERFORM AFTER-GOBACK-TARGET
           CALL 'SUBPGM1'
           PERFORM RETURN-TO-MENU
           PERFORM LOOP-PARA.
       RETURN-TO-MENU.
           MOVE 'Y' TO WS-FLAG
           PERFORM IN-RETURN-PARA-TARGET.
       LOOP-PARA.
           PERFORM VARYING WS-I FROM 1 BY 1 UNTIL WS-I > 5
              IF WS-I = 3
                 EXIT PERFORM
              END-IF
              DISPLAY WS-I
           END-PERFORM
           PERFORM AFTER-EXIT-PERFORM-TARGET
           PERFORM TEST AFTER VARYING WS-I FROM 1 BY 1
                   UNTIL WS-I > 2
              DISPLAY WS-I
           END-PERFORM.
       ENTRY-TARGET.
           DISPLAY 'E'.
       AFTER-GOBACK-TARGET.
           DISPLAY 'A'.
       IN-RETURN-PARA-TARGET.
           DISPLAY 'R'.
       AFTER-EXIT-PERFORM-TARGET.
           DISPLAY 'X'.

Found by a grep-vs-engine count audit of every mainframe file in language-crucible v1.7.0 (802 of 815 files compared), on main 737cab8 and the #4290 head (now merged as c136f46).

Activity

  1. added
    bug
    core-engine
    legacy-modernization
    priority: high
    on Oct 4, 2026
  2. added
    scope:core
    era:2
    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

    bugcore-engineera:2legacy-modernizationpriority: highscope:core

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions