Skip to content

cobol usage_status: entry paragraph flagged, case-sensitive matching, and NAME-EXIT counts as a reference to NAME #3198

Closed

Description

@squid-protocol

Found by the #3120 differential. function_data.usage_status is the same-file "is the name mentioned anywhere outside the unit" test (detector.py _is_orphan). For COBOL paragraphs and sections that misfires in three verified ways.

Micro-repro (verified on main)

       PROCEDURE DIVISION.
       MAIN-PARA.
           perform a-para.
           PERFORM B-PARA-EXIT.
           STOP RUN.
       A-PARA.
           DISPLAY 'A'.
       B-PARA.
           DISPLAY 'B'.
       B-PARA-EXIT.
           EXIT.
       C-PARA.
           DISPLAY 'C'.
unit usage_status truth
MAIN-PARA 1 live: the entry, reached by fall-through, never PERFORMed
A-PARA 1 live: perform a-para (COBOL names are case-insensitive)
B-PARA 0 only mentioned as the prefix of B-PARA-EXIT; (?!\w) lets - follow
B-PARA-EXIT 0 live
C-PARA 1 correct

On real corpora

  • zopeneditor-sample: all 5 flagged units are entry points (000-MAIN ×4) or an Area-B phantom (the phantom issue is filed separately).
  • CBSA: 248 units flagged.
    • 27 disagree with a reachability reading: PREMIERE SECTION in 17 programs, its first paragraph A010 in 7, 2 phantoms. One is a genuine true positive, CALC-DAY-OF-WEEK SECTION.
    • Sections whose paragraphs are reached by fall-through read 0 only because the api rule marks them is_public, not because anything models fall-through.

Why it matters

#3120/#3122 want usage_status to replace the refraction pipeline's dead-code x-ray. As it stands it flags exactly the code that always runs, so the pipeline records it but cannot use it (see docs/refraction_engine_differential.md D2).

Options (not pre-decided)

  • Minimum: case-insensitive matching for case-insensitive languages; - as a name character in COBOL's boundary; the first unit after PROCEDURE DIVISION treated as the entry.
  • Fuller: a COBOL invocation_model that follows PERFORM/GO TO/THRU from the entry, with SECTION fall-through. That is a reachability pass rather than a by-name census.

Any change moves the state_unreferenced / api-orphan census, so the rosetta cobol plants need re-checking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnintended behavior or logic failure in the enginecore-engineModifications to the central physics and parsing enginelegacy-modernizationCOBOL refractor, dead-code extraction, and JCL forging

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions