rexxfile #19
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!19
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "rexxfile"
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?
PR Review: Shebang Support and Exit Code Handling
I've reviewed PR #19 which adds shebang line support and proper exit code handling to the REXX interpreter. Overall, the implementation is sound and well-tested. Here are my findings:
✅ What's Good
Shebang Handling (src/lexer.rs:214-222)
#!at position 0 onlypeek_ahead(1)to verify both characters before skippingExit Code Handling (src/main.rs:86-88)
to_string().trim().parse().unwrap_or(0)for graceful fallback on non-numeric values (matches REXX semantics)EXITwith no value (returns 0)Exit(Some(val))correctly propagates from evaluator (src/eval.rs:390-396)Test Coverage (tests/rexxfile.rs)
🔍 Potential Issue: Shebang Not Consumed After Break
Location: src/lexer.rs:217-218
The shebang skipping logic breaks when it finds
\nbut doesn't consume it. However, this appears intentional because:Eoltoken as the first token after shebang (src/lexer.rs:647)EoltokenVerdict: Not a bug, but consider adding a comment explaining why the newline isn't consumed:
🎯 Summary
No blocking issues. The implementation correctly handles:
The code is production-ready. The only suggestion is the clarifying comment above.
Recommendation: ✅ Approve and merge
Code Review - PR #19: rexxfile
CRITICAL ISSUE - Exit code overflow behavior (src/main.rs:87):
The line
val.to_string().trim().parse::<i32>().unwrap_or(0)silently converts unparseable values to 0.Test cases that demonstrate the problem:
REXX semantics require EXIT value to be:
Recommend: Add proper validation with REXX error codes (BadArithmetic/InvalidWholeNumber/ArithmeticOverflow) instead of silent conversion to 0.
Minor issue - Shebang handler (src/lexer.rs:216-221):
The newline after shebang is not consumed. This is safe but slightly inconsistent with comment handling.
Otherwise: Excellent test coverage, no safety issues, proper error handling. Nice work!
PR Review: Shebang Support and EXIT Code Handling
I've reviewed this PR focusing on REXX semantics, error handling, arithmetic operations, and edge cases.
Summary
✅ Overall: Clean implementation with good test coverage
The PR adds shebang support and proper EXIT code propagation to the process exit status. The implementation is sound with one minor observation.
Detailed Analysis
1. Shebang Implementation (
src/lexer.rs:214-222)✅ Correct
pos == 0(file start)#!sequence usingpeek_aheadwhile let Some)TokenKind::Eolfollowed by first statement tokensEdge cases handled:
peek() == Nonepos == 0guard2. EXIT Code Handling (
src/main.rs:86-100)✅ Correct REXX semantics
Validation chain:
to_decimal()→ Error 41 (BadArithmetic) if non-numericround(0)→ round to integerd != rounded→ Error 26 (InvalidWholeNumber) if fractionalparse::<i32>().unwrap_or(1)→ handle overflowError numbers:
Minor observation (not a bug):
rounded.to_string().parse::<i32>()could theoretically fail if BigDecimal emits scientific notation (e.g.,1e10), but:round(0), BigDecimal typically emits plain integersunwrap_or(1)gracefully handles parse failuresunwrap_orREXX compliance:
3. Test Coverage (
tests/rexxfile.rs)✅ Comprehensive
Shebang tests:
EXIT tests:
Not tested (probably not needed):
unwrap_or(1)4. Safety & Correctness
✅ No panics
unwrap()calls are on infallible operationsunwrap_or(1)for fallback✅ No undefined behavior
peek()/peek_ahead()✅ Arithmetic operations (verified via separate analysis)
from_decimal()✅Recommendation
✅ Approve and merge
This is a clean, well-tested implementation. The minor observation about scientific notation is not a practical concern and is already handled defensively.
Files Reviewed
src/lexer.rs: Shebang handlingsrc/main.rs: EXIT code propagationtests/rexxfile.rs: Integration testsexamples/rexxfile: Practical usage example (verified syntax)No issues with REXX semantics, error handling, or safety.