⏺ Phase 5 is fully complete. Here's the summary: #6
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!6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "phase5"
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?
The remaining clippy fixes were:
PR Review: Phase 5 Built-in Functions
Summary
Reviewed 1,650 lines of REXX built-in function implementations. Found 3 critical correctness bugs and 3 performance issues. Overall, the implementation demonstrates solid understanding of REXX semantics, but has overflow handling gaps in conversion functions.
✅ What's Done Well
as_str()and handle conversionsunwrap()calls are actually safe due to prior validation (e.g., B2X line 1199, X2B line 1218)🔴 Critical Issues (Must Fix)
1. Integer Overflow in C2D with length parameter (src/builtins.rs:1053-1059)
Problem: When
length > 16, this silently overflowsi128and produces incorrect results.Impact:
C2D(string, 17)or higher will wrap around and return wrong values.Fix: Check
length <= 16and return Error 41 (BadArithmetic) if exceeded, or use arbitrary-precision arithmetic.2. Integer Overflow in C2D without length parameter (src/builtins.rs:1068-1072)
Problem: Input strings > 16 bytes silently overflow
u128.Impact:
C2D('17+ byte string')returns incorrect values.Fix: Check string length ≤ 16 bytes, or use arbitrary-precision arithmetic.
3. Quadratic Performance in Byte Padding (src/builtins.rs:1236-1238, 1247-1249)
Problem: Repeatedly calling
insert(0, ...)shifts all elements each iteration.Impact: D2C with large length values (e.g., 10,000) will hang or be extremely slow.
Fix: Build new vec:
⚠️ Should Fix (Performance)
4. Missing capacity pre-allocation in X2C (src/builtins.rs:1170)
5. Missing capacity pre-allocation in B2X (src/builtins.rs:1196)
6. Unnecessary clones in INDEX (src/builtins.rs:302-308)
Could restructure to avoid cloning by building argument slice differently.
📋 Test Coverage Gaps
The phase5 test suite has only 1 test for C2D:
Missing tests for:
📍 Line-by-Line Citations
✅ Verified Correct
RexxValue::from_decimalRecommendation
Implementation is solid overall but needs fixes for 3 critical issues before merge:
Code Review — PR #6: Phase 5 Built-in Functions
I've reviewed this PR focusing on correctness, arithmetic handling, error handling, REXX semantics, safety, and performance as requested.
Summary
Overall: Strong implementation with excellent test coverage (92 tests). The code is well-structured, handles edge cases properly, and follows REXX semantics correctly. Found 1 minor code quality issue.
Issues Found
1. Misleading fallback in X2D signed conversion ⚠️ Minor
Location:
src/builtins.rs:1157Issue: The
.unwrap_or(i128::MAX)fallback is logically incorrect. Iftry_fromfails, returningi128::MAXwould produce wrong results.Analysis: This code only executes when
bits < 64(line 1155 guard), somodulus = 1u128 << bitswill be < 2^64, meaningtry_fromwill succeed. The fallback is unreachable but misleading.Recommendation: Replace with
.expect("modulus fits in i128 when bits < 64")to document the invariant, or remove the guard and add proper error handling for large lengths.Correctness Review ✅
Arithmetic
with_scale_roundwith RoundingMode::DownError Handling
?operators propagate errors correctlycheck_argshelperREXX Semantics
eq_ignore_ascii_case(line 722).chars()throughout for Unicode correctness (e.g., substr_chars, char_len)Conversion Functions
Safety Review ✅
No Panics on Malformed Input
char_indicesfor byte-boundary safetyVec<char>indicesfrom_str_radixcalls use.map_err()(lines 1150, 1163, 1200)No Deep Nesting Issues
Performance Review ✅
No Unnecessary Allocations
No Quadratic Operations
write!macro instead offormat!+push_strper clippy fixesTest Coverage Review ✅
run_rexx_failhelperNitpicks (Non-blocking)
These are already addressed or acceptable as-is:
.unwrap_or(0)is defensive but unnecessary (input pre-validated)Conclusion
Recommendation: ✅ Approve with minor comment
The implementation is solid, comprehensive, and follows REXX semantics correctly. The one issue found is a code quality improvement (misleading fallback) rather than a bug. All 282 tests pass and clippy is clean.
Great work on Phase 5! 🎉
Code Review: Phase 5
Strong implementation overall. Found one critical issue with C2D signed conversion at builtins.rs:1070-1078. The code should accumulate bytes as u128 not i128 for proper two's complement. Test: C2D with FF and length 1 should return -1.
Other findings: X2D expect message, RANDOM seed support, template clones. All minor.
Verdict: APPROVE with C2D fix required before merge. Excellent REXX compliance otherwise.