⏺ Summary #9
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!9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "phase8"
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 8 (ADDRESS and External Commands) is complete. Here's what was implemented:
Files Modified
┌─────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ File │ Changes │
├─────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ src/env.rs │ Added address_default, address_previous fields + address(), set_address(), swap_address() methods │
├─────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ src/parser.rs │ Added parse_address() method, wired into parse_clause() keyword dispatch │
├─────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ src/eval.rs │ Added exec_address() and exec_host_command(), updated Command handler to execute commands via shell │
├─────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ src/builtins.rs │ Added ADDRESS() BIF returning current address environment │
├─────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ tests/phase8.rs │ New — 28 integration tests │
└─────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────┘
What Works Now
Test Results
PR Review: Phase 8 (ADDRESS and External Commands)
Summary
This PR implements the ADDRESS instruction and external command execution for the REXX interpreter. The implementation is mostly sound with proper error handling and REXX semantics compliance. All 28 tests pass and clippy is clean.
Critical Issue
Signal propagation bug in temporary ADDRESS execution (src/eval.rs:290-307)
In
AddressAction::Temporary, whenexec_host_commandreturns aSignalvariant (due to ERROR or FAILURE condition), the signal is captured but then the address is restored and the function returnsOk(signal). This correctly propagates the signal upward.However, there's a subtle issue: if the command triggers an ERROR/FAILURE trap that jumps to a label, the address restoration happens after the trap fires but before the signal propagates. This is actually correct per REXX semantics - the temporary address should be restored even when a condition occurs.
Actually, upon closer inspection, this is implemented correctly. The temporary address is properly restored before returning the signal. ✓
REXX Semantics Review
✓ Command execution: Commands are correctly executed via
sh -cwith stdout/stderr passthrough✓ RC variable: Exit codes are properly stored in RC special variable
✓ ADDRESS environments: Default "SYSTEM", swap behavior, and temporary execution are all correct
✓ ADDRESS() BIF: Returns current environment name as expected
✓ ERROR condition: Fires when rc != 0, sets condition info, removes trap (one-shot behavior)
✓ FAILURE condition: Fires when command can't be spawned
✓ Case insensitivity: Environment names are uppercased (src/parser.rs:1178, src/eval.rs:286)
✓ Condition info fields: Properly populated with condition, description, instruction, status
Observations (Not Issues)
CONDITION info
instructionfield (src/eval.rs:328, 342)The
instructionfield is hardcoded to"SIGNAL". Per ANSI X3.274-1996, this should typically be the instruction that caused the condition (e.g., the command string itself for ERROR/FAILURE). However, since REXX condition traps always use SIGNAL semantics, this is arguably acceptable. Thedescriptionfield contains the command, which provides the necessary context.Platform dependency
Using
sh -cfor command execution makes this Unix/Linux-specific. Windows would requirecmd /c. This is a known limitation and doesn't affect correctness on the target platform.status.code() handling (src/eval.rs:319)
status.code().unwrap_or(-1)correctly handles the case where the signal was terminated (no exit code). This matches REXX conventions.Code Quality
✓ No unnecessary clones in critical paths
✓ No panics on malformed input
✓ String operations are linear (no quadratic behavior)
✓ Proper use of BigDecimal (though not exercised in this PR)
✓ Consistent error handling patterns
✓ Test coverage is comprehensive (28 tests covering main paths and edge cases)
Performance Notes
The implementation is efficient:
to_uppercase()calls are minimal and unavoidable (src/parser.rs:1178, src/eval.rs:286)std::mem::swap(src/env.rs:195) - optimalto_string()calls in error paths are acceptable (src/eval.rs:298, 300)Parser Edge Cases
✓ Bare ADDRESS (swap) handled correctly (src/parser.rs:1159-1163)
✓ ADDRESS VALUE with expression support (src/parser.rs:1167-1173)
✓ ADDRESS env command (temporary) correctly parses full expression (src/parser.rs:1190)
✓ Error message for invalid ADDRESS syntax is clear (src/parser.rs:1200-1202)
Test Coverage Analysis
The test suite covers:
Missing test: Command with shell metacharacters or quotes (e.g.,
'echo "hello world"'). This would verify proper shell argument handling. However, since the implementation usessh -cwith a single string argument, this should work correctly.Verdict
LGTM ✅
The implementation correctly follows REXX semantics per ANSI X3.274-1996. No correctness, arithmetic, error handling, or safety issues found. The code is well-tested, efficient, and integrates cleanly with the existing codebase.
Minor suggestion: Consider adding a test for commands with shell special characters to verify the
sh -cintegration handles complex command strings correctly.Reviewed focusing on REXX semantics, error handling, parser edge cases, and safety. Style and documentation not reviewed per request.