Repository navigation
COBOL: a COPY / EXEC SQL INCLUDE after a separator period on the same line is an import (#4303) - #4350
Merged
Conversation
… line is an import (#4303) The `import` and `_dependency_capture` rules anchored COPY at line start, so `01 WS-REC. COPY CPYB.` and `01 PARENT. COPY A. COPY B. COPY C.` drew no import and no edge, while record_data already read those members. A COPY or a full EXEC SQL INCLUDE now also opens a statement after a separator period, each occurrence its own match; a bare INCLUDE still counts only at line start (the second line of the two-line EXEC SQL form). estate-crucible v0.3.0 H-0004: FAIL -> PASS. Golden masters regenerated in both legs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FNWHcUSn5p7eMxFTsB5rFo
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4303
What was broken
The COBOL
importand_dependency_capturerules anchoredCOPYat the start of a line (^+ sequence area + blanks). Two shapes were therefore never seen:01 WS-REC. COPY CUSTREC.01 PARENT. COPY A. COPY B. COPY C.file_data.raw_importsstayed empty and no import edge was drawn, even thoughrecord_data.copy_membersalready listed those members.The fix
A
COPYor a fullEXEC SQL INCLUDEnow also starts a statement when it follows a separator period on the same line, and each occurrence is its own match. Line-start matching is unchanged.A bare
INCLUDEstill counts only at line start, where it is the second line of the two-lineEXEC SQL/INCLUDE Xform. Elsewhere it would be ambiguous.I chose the period anchor rather than "COPY anywhere" because the code stream keeps literals. Blanking literals would also blank quoted members (
COPY 'CSUTLDWY'). "After a separator period" is the statement boundary IBM's grammar gives for this shape, and it can't fire insideDISPLAY '...'.Evidence
estate-crucible v0.3.0, H-0004 (
apps/ACCT/cobol/ACCTRPT.cbl,01 WS-RPT-HEAD. COPY RPTHDR./01 WS-RPT-TOTALS. COPY RPTTOT. COPY RPTCNT.):RPTHDR @21,RPTTOT @22,RPTCNT @22; fail layoutsWS-RPT-HEAD @21(+1)copieslayoutsNo other horror's verdict changed, and no channel got worse.
The issue's REPRO6 now gives
raw_imports = [CPYB, CPYC, CPYD]and 3importhits, which agrees withrecord_data.copy_members(CPYB,CPYC,CPYD).Tests in
tests/extraction/languages/test_cobol.py:. INCLUDE-FLAG, and a bare. INCLUDE Y.mid-line;[A, B, C]from both rules;..Golden-master diff (both legs regenerated: 88 diffs each)
TEST.CBLgoes from[]to[A, B, C](line 18).outline.cblgoes from[]to[AST](line 18).TEST.CBLgainsimport:hlasm/che4z_hlasm/A.hlasmand…/B.hlasm.CandASTdon't resolve._narrow_ambiguousonly restricts a source-member import to the importer's own language when there are several candidates. A single candidate in another language (A.hlasm) is still taken.testing_A.cpyCOPY B→B.hlasm.imports_unknown+4.pytest -m golden_cruciblepasses in both venvs.Ground-truth ledger
ground_truth_ledger.py checkis clean.tests/cobol_mainframe,tests/extractionandtests/core_enginepass with the pinned corpora (12,922), completeness pins included.Local checks
mypy_audit --ci,ruff_audit --ci(0.16.0),dead_key_audit --ci: nothing new.🤖 Generated with Claude Code