fix: Resolve MIR phi value bug and HTTP error handling

- Fix MIR builder to correctly return phi values in if-else statements
  - Add extract_assigned_var helper to handle Program blocks
  - Update variable mapping after phi node creation
  - Fixes 'Value %14 not set' error in e2e_vm_http_client_error_result

- Fix HTTP plugin error handling for connection failures
  - Return error string instead of handle on tcp_ok=false
  - Enable proper ResultBox(Err) creation for failed connections
  - Now r.isOk() correctly returns false for connection errors

- Add VM fallback for toString() on any Box type
  - Ensures error messages can be displayed even without specific implementation

- All e2e_vm_http_client_error_result tests now pass

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-23 06:51:49 +09:00
parent 3b03d001ba
commit 494a864ed2
5 changed files with 123 additions and 8 deletions

View File

@ -590,9 +590,14 @@ impl PluginBoxV2 {
}
6 | 7 => { // String/Bytes
let s = String::from_utf8_lossy(payload).to_string();
let val: Box<dyn NyashBox> = Box::new(StringBox::new(s));
if dbg_on() { eprintln!("[Plugin→VM] return str/bytes len={} (returns_result={})", size, returns_result); }
if returns_result { Some(Box::new(crate::boxes::result::NyashResultBox::new_ok(val)) as Box<dyn NyashBox>) } else { Some(val) }
if returns_result {
// Heuristic: for Result-returning methods, string payload represents an error message
let err = crate::exception_box::ErrorBox::new(&s);
Some(Box::new(crate::boxes::result::NyashResultBox::new_err(Box::new(err))) as Box<dyn NyashBox>)
} else {
Some(Box::new(StringBox::new(s)) as Box<dyn NyashBox>)
}
}
9 => {
if dbg_on() { eprintln!("[Plugin→VM] return void (returns_result={})", returns_result); }