⏺ Phase 12A is complete. Here's a summary of all changes: #15
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
rust
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/patch-rexx!15
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "phase12a"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Phase 12A: ANSI Conformance Fixes — Complete
Changes Made
src/parser.rs — Added parsing for NUMERIC, PUSH, QUEUE instructions
src/eval.rs — Implemented execution
src/lexer.rs — Newlines and line continuation
src/builtins.rs — New BIFs
tests/phase12a.rs — 28 integration tests covering all new features
Test Results
PR Review: Phase 12A ANSI Conformance Fixes
I've reviewed the changes for NUMERIC instructions, PUSH/QUEUE/PULL data queue, new BIFs, and line continuation. Here are my findings:
Critical Issues
1. NUMERIC DIGITS overflow vulnerability (src/eval.rs:1117-1125)
The code converts
to_integerresult directly tou32without checking if it exceedsu32::MAX:Impact:
NUMERIC DIGITS 5000000000(5 billion) would silently truncate, causing incorrect arithmetic precision.Fix: Add upper bound validation before cast:
ANSI X3.274-1996 §9.3.2 requires implementations to support at least DIGITS 9, but allows implementations to set maximum limits. Per spec, exceeding implementation limits should raise Error 26 (Invalid whole number).
2. NUMERIC FUZZ overflow (src/eval.rs:1161-1169)
Same vulnerability as DIGITS — missing upper bound check before
n as u32cast.Arithmetic & Error Handling ✓
Division by zero handling is correct for all division operations:
All use Error 42 (ArithmeticOverflow) per ANSI spec §A.4.42 — correct error number for division by zero.
REXX Semantics ✓
PUSH/QUEUE/PULL implementation follows REXX semantics correctly:
push_front) — verified by test at line 756push_back) — verified by test at line 770pull_from_queue_or_stdin(src/eval.rs:1217)QUEUED() BIF correctly returns
self.queue.len()— no off-by-one errors.NUMERIC FORM validation is correct (src/eval.rs:1141-1149):
Lexer Line Continuation
Potential edge case in
is_line_continuation(src/lexer.rs:149-187):The block comment scanning doesn't handle unterminated comments at end of line:
Current code would scan past EOF looking for
*/, then returntrue(treating EOF as continuation). This is benign — the unterminated comment would be caught by the later comment parsing inskip_whitespace_and_comments, producing Error 6 (UnmatchedComment).Not a bug, but the control flow is indirect. Consider adding a safety check:
Test Coverage ✓
Phase12a tests are comprehensive:
Missing test: NUMERIC DIGITS with value > u32::MAX (would expose the overflow bug).
Performance
No performance issues detected:
VecDequefor queue is correct choice (O(1) push/pop on both ends)Summary
Must fix before merge:
Recommended:
3. Add test case for large NUMERIC DIGITS values
The implementation is otherwise sound. Division by zero handling is correct, REXX semantics are properly followed, and the queue implementation matches the ANSI spec.
Code Review: Phase 12A ANSI Conformance Fixes
I've reviewed this PR focusing on correctness, REXX semantics, error handling, and potential issues. The implementation is solid overall, but I've identified one critical bug and several improvement areas.
What's Working Well
Critical Issue
Line continuation with unterminated block comments can cause infinite loop or panic
Location: src/lexer.rs:149-187 (is_line_continuation())
Problem: The block comment handling in is_line_continuation() doesn't check for EOF while skipping nested comments. If a trailing comma is followed by an unterminated /* comment, the while loop can exit with depth > 0, but the function continues instead of returning an error.
Impact: Could cause incorrect parsing or allow unterminated comments to be silently accepted during line continuation detection.
Fix needed: After the while loop exits at line 178, add:
Test case to add:
This should fail with an unterminated comment error, not silently continue.
ANSI Compliance & Semantics Issues
1. PARSE PULL does not uppercase in tests, but spec is unclear
Locations:
Issue: Test comments say "PARSE PULL does not uppercase (only shorthand PULL does)" but the code at src/eval.rs:905 shows that ParseSource::Pull calls pull_from_queue_or_stdin() which returns raw text, and then the PARSE instruction applies uppercasing based on the upper flag.
Questions:
Verify: Check if the parser distinguishes PARSE PULL from PARSE UPPER PULL and if tests cover both cases.
2. NUMERIC FORM bare keyword defaults to SCIENTIFIC
Location: src/parser.rs:1524 (line 522 in diff)
Question: Is this correct per ANSI X3.274-1996? Some REXX implementations treat bare NUMERIC FORM as an error. Please verify this is the intended default behavior.
Potential Performance Issues
String clones in PUSH/QUEUE
Location: src/eval.rs:1200, src/eval.rs:1215
This is called on every PUSH/QUEUE. Since RexxValue already owns the string, you could use into_string() to avoid the clone if the value isn't used afterward.
Test Coverage Gaps
Line continuation edge cases:
NUMERIC DIGITS edge cases:
NUMERIC FUZZ edge cases:
Queue edge cases:
Recommendations
Must fix before merge:
Should consider:
Nice to have:
Summary
The implementation correctly handles the ANSI REXX semantics for NUMERIC settings and the data queue. Error handling is proper with correct error numbers. The critical issue is in the lexer's line continuation logic with unterminated comments. Fix that, verify the PARSE PULL uppercase behavior, and this will be ready to merge.
Overall assessment: Solid implementation with one critical fix needed.
File-specific issues cited: