🔧 Fix LLVM basic block naming collision (ChatGPT5)
- Add function name prefix to basic block labels to avoid cross-function conflicts - blocks.rs: create_basic_blocks now takes fn_label parameter - Format: 'Main_join_2_bb23' instead of just 'bb23' - Add conservative fallback for missing terminators (jump to next or entry) - This fixes 'Basic Block does not have terminator' verification error Analysis insights: - MIR output was correct (all blocks had terminators) - Problem was LLVM-side block name collision between functions - Classic case of 'Rust complexity' - simple C++ style fix works best - Sometimes the simplest solution is the right one\!
This commit is contained in:
@ -71,6 +71,27 @@ pub(in super::super) fn lower_boxcall<'ctx>(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Minimal untyped fallback: Array.length with missing annotations
|
||||
if method == "length" && args.is_empty() {
|
||||
let fnty = i64t.fn_type(&[i64t.into()], false);
|
||||
let callee = codegen
|
||||
.module
|
||||
.get_function("nyash_array_length_h")
|
||||
.unwrap_or_else(|| codegen.module.add_function("nyash_array_length_h", fnty, None));
|
||||
let call = codegen
|
||||
.builder
|
||||
.build_call(callee, &[recv_h.into()], "alen_fallback")
|
||||
.map_err(|e| e.to_string())?;
|
||||
if let Some(d) = dst {
|
||||
let rv = call
|
||||
.try_as_basic_value()
|
||||
.left()
|
||||
.ok_or("array_length_h returned void".to_string())?;
|
||||
vmap.insert(*d, rv);
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Some(mid) = method_id {
|
||||
invoke::try_handle_tagged_invoke(
|
||||
codegen,
|
||||
|
||||
Reference in New Issue
Block a user