feat(joinir): Phase 188 StringAppend support in Pattern2/4
- Extended Pattern2/4 whitelist to accept StringLiteral updates - CarrierUpdateEmitter now emits JoinIR for string append - Selective Fail-Fast: accept safe patterns, reject complex Changes: - pattern2_with_break.rs: StringLiteral whitelist - pattern4_with_continue.rs: StringLiteral whitelist - carrier_update_emitter.rs: StringLiteral JoinIR emission Tests: - phase188_string_append_char.hako - phase188_string_append_literal.hako - 10/10 carrier_update_emitter tests PASS 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -356,6 +356,48 @@ Add Phase 187 entry:
|
||||
|
||||
---
|
||||
|
||||
## Phase 188 Implementation Complete (2025-12-09)
|
||||
|
||||
### Implementation Summary
|
||||
|
||||
Phase 188 successfully implemented StringAppendChar and StringAppendLiteral support in JoinIR patterns.
|
||||
|
||||
**Changes Made**:
|
||||
|
||||
1. **Pattern2/4 `can_lower()` Whitelist** (Task 188-2)
|
||||
- Updated `pattern2_with_break.rs` and `pattern4_with_continue.rs`
|
||||
- Allow: `UpdateRhs::Const`, `UpdateRhs::Variable`, `UpdateRhs::StringLiteral`
|
||||
- Reject: `UpdateRhs::Other` (complex updates only)
|
||||
- Old behavior: Rejected all string updates
|
||||
- New behavior: Accept safe string patterns, reject only complex ones
|
||||
|
||||
2. **CarrierUpdateLowerer JoinIR Emission** (Task 188-3)
|
||||
- Updated `carrier_update_emitter.rs` (both UpdateEnv and ConditionEnv versions)
|
||||
- `UpdateRhs::StringLiteral(s)` → Emit `Const { value: ConstValue::String(s) }` + `BinOp`
|
||||
- `UpdateRhs::Variable(name)` → Resolve variable, emit `BinOp` (handles both numeric and string)
|
||||
- `UpdateRhs::Other` → Return error (should be caught by can_lower)
|
||||
|
||||
3. **E2E Test Files** (Task 188-4)
|
||||
- Created `apps/tests/phase188_string_append_char.hako` (Pattern 2 with break)
|
||||
- Created `apps/tests/phase188_string_append_literal.hako` (Pattern 4 with continue)
|
||||
- Both tests compile and run without errors
|
||||
- JoinIR generation succeeds for both patterns
|
||||
|
||||
**Verification**:
|
||||
```bash
|
||||
# Pattern 2: StringAppendChar
|
||||
NYASH_JOINIR_CORE=1 ./target/release/hakorune apps/tests/phase188_string_append_char.hako
|
||||
# Output: Pattern 2 triggered, JoinIR generated successfully
|
||||
|
||||
# Pattern 4: StringAppendLiteral
|
||||
NYASH_JOINIR_CORE=1 ./target/release/hakorune apps/tests/phase188_string_append_literal.hako
|
||||
# Output: Pattern 4 triggered, JoinIR generated successfully
|
||||
```
|
||||
|
||||
**Key Achievement**: Phase 178's Fail-Fast is now selective - only rejects truly complex updates (method calls, nested BinOp), while allowing safe string concatenation patterns.
|
||||
|
||||
---
|
||||
|
||||
## 10. Conclusion
|
||||
|
||||
Phase 187 establishes a clear design for string update handling in JoinIR:
|
||||
|
||||
Reference in New Issue
Block a user