Repository navigation
det: P-scaled PICTUREs as cobc stores them, the rest refused by name (#4669, #4670) - #4685
Merged
Merged
Conversation
…ed by name (#4669, #4670) A P is a scaling position, never stored: Item.digits counts a numeric item's 9s and Item.scale counts the Ps (99PP: 2 digits, scale -2; VPP99 / PP99: 2 digits, scale 4). PIC SVPP99 COMP-3 no longer crashes the layout (ValueError) and MOVE 1200 TO a 99PP item no longer throws in Cobol.store. A right-P item MOVEd to an alphanumeric gets a zero per P (Cobol.sourceText), as GnuCOBOL does. Refused by name where GnuCOBOL 3.1.2 gives no usable oracle: P-scaled COMP-3 (mis-stored), right-P / COMP-5 binary (loops on MOVE 0), DISPLAY of a P-scaled item (cobc shows 99PP VALUE 1200 as 0012), a P-scaled operand in a condition's arithmetic expression, and a right-P operand in a COMPUTE with a division or three operands (cobc's intermediate precision for it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MQNoe4wPJgr7dbUvs3DG6D
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MQNoe4wPJgr7dbUvs3DG6D
squid-protocol
marked this pull request as ready for review
October 8, 2026 17:09
squid-protocol
added a commit
that referenced
this pull request
Oct 8, 2026
Conflict in Gen's COMPUTE: keep #4685's p_scaled_expr refusal (first) and this PR's ARITHMETIC-OSVS plan around the expression. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MQNoe4wPJgr7dbUvs3DG6D
squid-protocol
added a commit
that referenced
this pull request
Oct 8, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MQNoe4wPJgr7dbUvs3DG6D
squid-protocol
added a commit
that referenced
this pull request
Oct 8, 2026
…e-error gen.py COMPUTE: this PR's float_statement(targets) kept with main's p_scaled_expr refusal (#4685). test_det_size_error.py: both branches already use the one `import test_det_programs as T` form (CodeQL). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MQNoe4wPJgr7dbUvs3DG6D
This was referenced Oct 11, 2026
Merged
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 #4669, Fixes #4670
Part of #4270. P-scaled PICTUREs in the det translator / runtime, measured against the oracle (cobc 3.1.2 -std=ibm) item by item.
Modelled
A P is a scaling position, never stored.
Item.digitsnow counts a numeric item's 9s andItem.scalecounts the Ps:99PP/99PPVare 2 digits at scale -2,VPP99/PP99are 2 digits at scale 4. Nothing else in the runtime needed to change for these:BigDecimal.setScale(-2)already truncates the way cobc does.1300). A left-P binary item gets its Ps as leading digits. Both match cobc (Cobol.sourceText).PIC SVPP99 COMP-3no longer crashes the layout with a ValueError: its image is IBM's 2 bytes. det runtime: MOVE 1200 into a 99PP item throws in Cobol.store #4670'sMOVE 1200into99PPnow stores 12 at scale -2.Refused by name (the oracle has no usable answer)
MOVE 5600 TO PIC S99PP COMP-3reads back as<600).MOVE 0intoPIC 99PP COMP.99PP VALUE 1200as0012andS99PP -3400as0034-.IF PR / 7 > 171andIF PR * 2 > 2399are false for 1200.(PR / 7) * PRwith truncated quotient digits, andI5 + PR * 0.5andB0 * .03 * PSas if the product were 0.The #4668 refusal (a P-scaled operand in a numeric-edited comparison) is not touched.
Shared functions touched (for the det/cobolrt train: #4654, #4677, #4663, #4666, #4668)
layout.py:Item.digits,Item.scale, newItem.p_scaled,Item.elementary_size(one line)gen.py: new module functionp_unmodelled,Gen.resolve(3 lines at its end),Gen._init_one(3 lines at its top),Gen.display_operand(3 lines),Gen.rel(numeric branch, 2 lines), new methodGen.p_scaled_expr, the COMPUTE branch of the statement translator (1 line)cobolrt/Cobol.java:sourceText(its two returns), new helperpZerosEvidence
tests/cobol_mainframe/test_det_programs.py), all 12 fail on origin/main and pass here:PSCALE: an end-to-end program run in bytes, typed and groups modes. It has about 140 output lines over 8 P-scaled items and is equal to GnuCOBOL.det_port.py checkvs origin/main: all 68 ports change, but only in the runtime'sCobol.java(17 lines). No service changed.proof_sweep.py --det-only: 65 PROVED, and 3 NOT PROVEN that are already in the baseline (carddemo-cardupdate, carddemo-intcalc-generated, mortgage-mpmt). Result "sweep: as expected".evidence_report.py --checkrc 0.test_evidence.pyandtest_evidence_report.py: 71 passed.pr_gates.py --fast: 5/5 pass.pr_gates.py --ratchets: 7 pass, 0 fail, 0 skipped.Follow-ups filed
NOTat the end of a line with its operator on the next crashes the PROCEDURE DIVISION parse (found by the fuzz, not P-related).🤖 Generated with Claude Code