fix(joinir): Phase 269 P1.2 - static call normalization for this.method()

Problem:
- `this.method()` calls in static box loops were using string constant "StringUtils" as receiver
- This violated Box Theory (static box this should not be runtime object)
- Pattern8 was trying to pass receiver to JoinIR, causing SSA/PHI issues

Solution (3-part fix):
1. **MeResolverBox Fail-Fast** (stmts.rs): Remove string fallback, error message cleanup
2. **ReceiverNormalizeBox** (calls/build.rs): Normalize `this/me.method()` → static call at compile-time
3. **Pattern8 Skip Static Box** (pattern8_scan_bool_predicate.rs): Reject Pattern8 for static box contexts

Key changes:
- **stmts.rs**: Update error message - remove MeBindingInitializerBox mentions
- **calls/build.rs**: Add This/Me receiver check, normalize to static call if current_static_box exists
- **calls/lowering.rs**: Remove NewBox-based "me" initialization (2 locations - fixes Stage1Cli regression)
- **pattern8_scan_bool_predicate.rs**: Skip Pattern8 for static boxes (use Pattern1 fallback instead)

Result:
-  phase269_p1_2_this_method_in_loop_vm.sh PASS (exit=7)
-  No regression: phase259_p0_is_integer_vm PASS
-  No regression: phase269_p0_pattern8_frag_vm PASS
-  Stage1Cli unit tests PASS
-  MIR uses CallTarget::Global, no const "StringUtils" as receiver

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-22 03:33:30 +09:00
parent 5f891b72ad
commit 4ef2261e97
6 changed files with 157 additions and 20 deletions

View File

@ -0,0 +1,46 @@
static box StringUtils {
equals(other) {
return true
}
is_digit(ch) {
// 元の実装を再現or チェーン)
return ch == "0" or ch == "1" or ch == "2"
}
is_integer(s) {
// 元の実装に近づける
if s.length() == 0 {
return false
}
local start = 0
if s.substring(0, 1) == "-" {
if s.length() == 1 {
return false
}
start = 1
}
local i = start
loop(i < s.length()) {
// 🔥 THIS IS THE BUG: this.is_digit() in loop
if not this.is_digit(s.substring(i, i + 1)) {
return false
}
i = i + 1
}
return true
}
toString() {
return "StringUtils()"
}
}
static box Main {
main() {
// 元のテストケースと同じ
return StringUtils.is_integer("123") ? 7 : 1
}
}