🚀 Major LLVM breakthrough by ChatGPT5\!

PHI type coercion and core-first routing fixes:
- Auto type conversion for PHI nodes (i64↔i8*↔i1↔f64)
- Fixed ArrayBox.get misrouting to Map path
- Core-first strategy for Array/Map creation
- Added comprehensive debug logging ([PHI], [ARR], [MAP])

Results:
 Array smoke test: 'Result: 3'
 Map smoke test: 'Map: v=42, size=1'

After 34+ minutes of battling Rust lifetime errors,
ChatGPT5 achieved a major breakthrough\!

Key insight: The bug wasn't in PHI/SSA logic but in
Box type routing - ArrayBox.get was incorrectly caught
by Map fallback due to missing annotations.

We're SO CLOSE to Nyash self-hosting paradise\! 🌟
Once this stabilizes, everything can be written in
simple, beautiful Nyash code instead of Rust complexity.
This commit is contained in:
Selfhosting Dev
2025-09-12 12:07:07 +09:00
parent 1f5ba5f829
commit 4fe1212d36
9 changed files with 203 additions and 14 deletions

View File

@ -25,6 +25,9 @@ pub(super) fn try_handle_array_method<'ctx>(
let i64t = codegen.context.i64_type();
match method {
"get" => {
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {
eprintln!("[LLVM] lower Array.get (core)");
}
if args.len() != 1 {
return Err("ArrayBox.get expects 1 arg".to_string());
}
@ -53,6 +56,9 @@ pub(super) fn try_handle_array_method<'ctx>(
Ok(true)
}
"set" => {
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {
eprintln!("[LLVM] lower Array.set (core)");
}
if args.len() != 2 {
return Err("ArrayBox.set expects 2 arg".to_string());
}
@ -80,6 +86,9 @@ pub(super) fn try_handle_array_method<'ctx>(
Ok(true)
}
"push" => {
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {
eprintln!("[LLVM] lower Array.push (core)");
}
if args.len() != 1 {
return Err("ArrayBox.push expects 1 arg".to_string());
}
@ -104,6 +113,9 @@ pub(super) fn try_handle_array_method<'ctx>(
Ok(true)
}
"length" => {
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {
eprintln!("[LLVM] lower Array.length (core)");
}
if !args.is_empty() {
return Err("ArrayBox.length expects 0 arg".to_string());
}