Investigation into Phase 173-2 (using resolver + MIR lowering) has revealed that **the Rust MIR builder already correctly handles static box method calls**. The issue described in the investigation findings document appears to be solved at the MIR generation level.
## Investigation Results
### Trace Evidence
Running with `NYASH_STATIC_CALL_TRACE=1` shows:
```
[DEBUG] 'JsonParserBox' not in variable_map - treating as static box, will use global call
**Issue Identified**: Line 4 shows `call_method` with receiver `%7` (which is never defined). This is inconsistent with the trace showing "static-call".
### Root Cause Hypothesis
The discrepancy between the trace output ("static-call") and the MIR dump ("call_method") suggests:
1.**MIR generation is correct** (trace confirms this)
2.**MIR dumping/printing may be showing outdated information** OR
3.**There's a transformation step after initial MIR generation** that's converting static calls back to method calls
### Current Error
```
[ERROR] ❌ [rust-vm] VM error: Invalid instruction: Unknown method '_skip_whitespace' on InstanceBox
```
This error occurs at **runtime**, not during MIR generation. The method `_skip_whitespace` is being called on an `InstanceBox` receiver instead of the correct static box.
- Added detection for using aliases in receiver position
- Added `is_static_box_call: true` flag to Method AST node when receiver is a using alias
**Note**: These changes are in `.hako` files and won't take effect until the Stage-3 parser is recompiled into the binary. This creates a chicken-and-egg problem for testing.
### Task 5: MIR Lowering Analysis
**Finding**: No Rust code modifications needed!
The existing Rust MIR builder code already handles static box calls correctly:
4.`src/backend/mir_interpreter/handlers/calls/` - VM call handlers
5.`src/mir/printer.rs` - MIR dump formatting (may explain discrepancy)
## Conclusion
Phase 173-2 investigation has revealed that:
1.**Parser changes implemented** (but need recompilation to test)
2.**MIR builder already works correctly** (no Rust changes needed at this level)
3.**Runtime issue exists** (VM execution or MIR transformation problem)
4.**Next action**: Debug MIR dump discrepancy and VM call handling
The core using resolver + MIR lowering integration is **functionally complete** at the design level. The remaining issue is a runtime execution problem that requires debugging the VM call dispatch mechanism.
---
**Created**: 2025-12-04
**Phase**: 173-2 (using resolver + MIR lowering)
**Investigation Time**: 2 hours
**Complexity**: Medium (Runtime debugging required)