Files
hakorune/apps/tests/phase257_p0_last_index_of_min.hako
tomoaki edc7355937 refactor(joinir): unify boundary join_inputs SSOT (pattern4/6/7)
Apply Phase 256.8 SSOT fix to Pattern4/6/7:
- Use join_module.entry.params.clone() instead of hardcoded ValueIds
- Add fail-fast validation for params count mismatch
- Remove ValueId(0), ValueId(PARAM_MIN + k) patterns
- Clean up unused PARAM_MIN imports

This prevents entry_param_mismatch errors structurally and maintains
consistency with Pattern2/3.

Changes:
- pattern4_with_continue.rs: Lines 442-476 (SSOT extraction + validation)
- pattern6_scan_with_init.rs: Lines 447-471 (SSOT extraction + validation)
- pattern7_split_scan.rs: Lines 495-526 (SSOT extraction + validation)

All patterns now use the same SSOT principle:
1. Extract entry function (priority: join_module.entry → fallback "main")
2. Use params as SSOT: join_inputs = entry_func.params.clone()
3. Build host_inputs in expected order (pattern-specific)
4. Fail-fast validation: join_inputs.len() == host_inputs.len()

Verification:
- cargo build --release:  PASS (no PARAM_MIN warnings)
- Quick profile:  First FAIL still json_lint_vm (baseline maintained)
- Pattern6 smoke:  PASS (index_of test)
- Pattern7 smoke: Pre-existing phi pred mismatch (not introduced by SSOT)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-20 20:05:11 +09:00

31 lines
675 B
Plaintext

// Phase 257 P0: Minimal last_index_of pattern
// Pattern: Loop with early return (backward scan)
//
// Structure:
// loop(i >= 0) {
// if (condition) { return value }
// i = i - 1
// }
// return default
//
// Target: Extend Pattern2 to handle return (similar to break)
static box Main {
main() {
local s = "hello world"
local ch = "o"
// Find last occurrence of ch in s
local i = s.length() - 1
loop(i >= 0) {
if s.substring(i, i + 1) == ch {
return i // Early return when found
}
i = i - 1 // Backward scan
}
return -1 // Not found
}
}