Skip to content

det parser: NOT split from its relational operator across lines; ZERO in condition arithmetic (#4674, #4656) - #4680

Merged
squid-protocol merged 1 commit into
mainfrom
fix/4674-4656-det-parser
Oct 8, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/4674-4656-det-parser

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Fixes #4674, Fixes #4656

Part of #4270.

What

  • det/stmt.py _join_not_breaks (new, called from parse): the grammar refuses a NOT split from its relational operator by a line break, and with it the whole PROCEDURE DIVISION. Two shapes are rejoined before parsing, keeping the line count (the break moves after the operator, with the next line's indent): NOT at a line end (IF S3 NOT / < 3, NOT / = x, IS NOT / GREATER THAN, NOT alone on a line, OR NOT / < 100, in IF / EVALUATE WHEN / PERFORM UNTIL), and a NOT <op> that starts a line after AND / OR. Literals with an odd quote count before the NOT are left alone.
  • det/expr.py Parser._paren_is_condition (+ ARITH_OPS): ZERO is a class word only after an operand; first in a parenthesised group or after an arithmetic operator it is a number, so IF (ZERO + 3) / 12 NOT > D0 and IF (ZERO / 12) * P0 > S3 parse. (The WHEN D0 + ZERO > x shape already parses on main; a regression test is added.)

Touched functions only: stmt.parse (one call), stmt._join_not_breaks, expr.Parser._paren_is_condition.

Tests

  • test_det_translate.py: test_a_relation_split_across_lines_or_with_zero_in_arithmetic_parses (10 shapes; 9 fail on main) and test_a_when_with_zero_in_arithmetic_is_a_condition; they also assert the statement after the IF keeps its line.
  • test_det_programs.py: programs SPLITNOT and ZEROARITH against cobc, bytes / typed / groups (6 cells; fail on main, pass now).
  • det_port.py check --base-ref origin/main: 68/68 ports unchanged (no corpus program was refused for this reason; no ledger change).
  • pr_gates.py --fast: 5/5 pass; --ratchets: 7 pass, 0 skipped.

Not covered

Fuzz seeds 12 and 23 from the #4655 run (the #4674 hits) now translate, but fail at runtime with a division by zero: that is #4655 / #4677 (zero divisor), not this PR.

🤖 Generated with Claude Code

… ZERO in arithmetic groups is a number (#4674, #4656)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol marked this pull request as ready for review October 8, 2026 14:40
@squid-protocol
squid-protocol merged commit 9cde37a into main Oct 8, 2026
37 checks passed
@squid-protocol
squid-protocol deleted the fix/4674-4656-det-parser branch October 8, 2026 14:40
squid-protocol added a commit that referenced this pull request Oct 8, 2026
…n-holes

stmt.py: main's _join_not_breaks (#4680) runs first, then this PR's
abbreviated AND/OR NOT = rewrite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MQNoe4wPJgr7dbUvs3DG6D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant