Phase 173-2 investigation has been completed successfully. Through detailed VM tracing and code analysis, I identified the root cause of the static box method resolution issue and proposed two alternative implementation strategies.
## What Was Accomplished ✅
### 1. Deep Investigation
- **VM Execution Tracing**: Used `NYASH_CALLEE_RESOLVE_TRACE=1` and `NYASH_DEBUG_FUNCTION_LOOKUP=1` to trace the complete execution flow
- **MIR Lowering Analysis**: Verified that static box internal calls (`me.method()`) correctly lower to `Callee::Global`
- **VM Function Lookup**: Confirmed all JsonParserBox methods are properly registered in the function table
- **Error Point Identification**: Pinpointed that the error occurs at the call site in Main, not in the VM execution
### 2. Root Cause Identified
**Problem**: Parser treats `JsonParserBox` as a **variable** (VarRef) instead of a **type** (TypeRef)
**Evidence**:
```
Main.main():
JsonParserBox.parse("{\"x\":1}")
↓ Parser treats "JsonParserBox" as variable (VarRef)
↓ MIR generates Callee::Method with undefined receiver
↓ Receiver defaults to "InstanceBox"
↓ ERROR: "Unknown method 'parse' on InstanceBox"
```
**Confirmed Working**:
- Internal static box calls: `me.method()` within JsonParserBox ✅
- Function registration: All methods in VM function table ✅
- Function lookup: VM successfully finds functions ✅
**Not Working**:
- External static box calls: `JsonParserBox.parse()` from Main ❌
### 3. Strategy Revision
**Original Plan Issues**:
- Violated "Rust VM不変" (Rust VM unchanged) principle
- Required complex .hako compiler modifications
- Introduced scope creep (essentially building a type system)
**Revised Recommendations**:
#### Option 1: Minimal Parser Fix (Recommended)
**Approach**: Detect `UsingAlias.method()` pattern in parser, emit StaticBoxCall AST node
**Changes required**:
1.**Parser** (.hako): Add using alias table lookup in call expression parsing (~30 lines)
2.**AST**: Add StaticBoxCall node type or flag to existing MethodCall