⏺ Phase 12B Complete #16
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!16
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "phase12b"
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?
Summary
Created: tests/conformance.rs — 75 ANSI X3.274-1996 conformance tests organized by spec section:
Bugs Found and Fixed
Verification
PR #16 Review: Phase 12B - ANSI X3.274-1996 Conformance Tests
Reviewed all changes with focus on correctness, REXX semantics, arithmetic, and error handling.
Critical Issues Found
1. ❌ CRITICAL: Power operator is right-associative, should be left-associative
Location:
src/parser.rs:1575-1588The parser implements
**as right-associative (via right-recursion), but ANSI X3.274-1996 REXX specifies left-associative evaluation for all operators including power.Impact:
2 ** 3 ** 2evaluates to512(2^9) but should be64((2^3)^2)sec8_power_right_assoc_execution(line 239) expects512but should expect64parse_power_right_assoc()(line 1760) also needs updatingFix: Change to left-associative loop like
parse_multiplication():2. ❌ CRITICAL: Numeric-starting compound tail elements treated as variables
Location:
src/parser.rs:1691-1702(parse_tail_elements)REXX Semantics: Any tail element starting with a digit is a constant, even if it contains letters.
Impact:
arr.3abcwould incorrectly try to look up variable3ABCinstead of using constant"3ABC"arr.123xyzwould fail similarlyFix:
3. ⚠️ MODERATE: Empty stem not validated
Location:
src/parser.rs:1639-1644The parser accepts symbols like
.foo(if tokenized as a single symbol) and createsExpr::Compound { stem: "", tail: [Var("FOO")] }.REXX Semantics: A stem must have at least one character before the dot.
Impact: Could lead to invalid compound variables with empty stems, causing undefined behavior in the environment.
Recommendation: Add validation:
Correct Implementations ✅
Assignment to stem default (
arr.)Location:
src/eval.rs:360-366Correctly distinguishes between stem default assignment and compound assignment:
✅ Test
sec7_stem_default_assignment(line 268) validates this correctly.Integer division (
%)Location:
src/eval.rs(viatrunc_div)Correctly implements truncation toward zero using
RoundingMode::Down.-7 % 2=-3(test line 437)Remainder (
//)Location:
src/eval.rs:1871-1886Correctly implements REXX remainder:
a // b = a - (a % b) * b-7 // 2=-1(test line 447)Division precision
Correctly implements
NUMERIC DIGITSwith half-up rounding.2/3withNUMERIC DIGITS 5=0.66667(test line 456)FORMAT overflow detection
Location:
src/builtins.rs:962-971Correctly errors when integer part exceeds requested width.
format(123,2,0)correctly errors (test line 883)TRANSLATE with pad char
Location:
src/builtins.rs:534-577Correctly pads output when output table is shorter than input table.
translate('abcde','12','abcde')="12 "(test line 765)translate('abcde','12','abcde','*')="12***"(test line 774)Test Coverage Assessment
The new conformance test suite is comprehensive and well-organized:
stdout()vsstdout_raw()for whitespace-sensitive testsOnly issue: Two tests have wrong expectations due to the power operator bug (#1 above).
Other Observations
Updated trace test (tests/phase9.rs:354-361)
✅ Correctly changed expected trace tag from
>V>to>C>for compound variable access, matching the fix that compounds are now properly parsed asExpr::Compound.No safety issues
No performance concerns
splitn(2, '.')appropriately stops after first splitSummary
Must fix before merge:
Should fix:
3. Empty stem validation
Zero regressions confirmed - the fixes are targeted and test coverage is excellent.
Reviewed with reference to ANSI X3.274-1996 REXX specification.
Code Review — Phase 12B
Reviewed for correctness, REXX semantics, arithmetic, error handling, performance, and safety. Overall the PR looks solid with comprehensive test coverage. Found one critical issue with compound variable tail parsing.
❌ Critical Issue: Incorrect tail element classification
Location: src/parser.rs:1700
Problem: The change from
.chars().all(|c| c.is_ascii_digit())to.starts_with(|c: char| c.is_ascii_digit())is incorrect.Impact: This breaks the REXX spec. According to ANSI X3.274-1996, tail elements that are purely numeric should be constants, while alphanumeric symbols should be variables.
arr.3→ tail"3"should be Const (✓ works before and after)arr.3a→ tail"3a"should be Var (✓ works before, ❌ broken after — now classified as Const)arr.a3→ tail"a3"should be Var (✓ works both)Example failure:
Why it matters: When
i="3a", with the new logicarr.iwill incorrectly resolve to the constant tail"3A"instead of treating it as a variable that would need substitution.Fix: Revert line 1700 to:
The original logic was correct. The change appears to have been made as part of the compound variable fix but wasn't necessary and introduces a bug.
✅ Correct Changes
1. Compound variable parsing in expressions (src/parser.rs:1638-1649)
.in expression positionarr.3.5returned "ARR.3.5" instead of stored value2. Stem default assignment (src/eval.rs:362-366)
arr.="value"(stem default) fromarr.key="value"(compound)set_stem_default()vsset_compound()3. Test update (tests/phase9.rs:354-357)
>V>(variable) to>C>(compound)✅ Test Coverage
The 75 new conformance tests are well-organized and comprehensive:
All tests pass (534 total), which is excellent.
Minor Observations (not blockers)
splitn(2, '.')is efficient — ✓Recommendation
Do not merge until the
parse_tail_elementslogic is fixed. The.starts_with()change must be reverted to.chars().all()to maintain spec compliance.After that fix:
Great work on the comprehensive test suite and the bug fixes! Just need to address the tail element classification issue.
Reviewed: src/{parser.rs, eval.rs}, tests/{conformance.rs, phase9.rs}
Compiler: ✓ clean
Tests: ✓ 534 passing
Spec compliance: ⚠️ needs tail element fix