This commit is contained in:
agra
2026-02-24 19:31:10 +02:00
parent 7a381e1b4c
commit 9dba8eef5b
4 changed files with 72 additions and 4 deletions

View File

@@ -6333,8 +6333,11 @@ pub const CodeGen = struct {
return entry.ptr;
}
}
// Non-identifier expressions (e.g. field access, tuple element):
// generate value, store into temp alloca, return alloca pointer
// Field access / index: take address of the lvalue directly (no copy)
if (node.data == .field_access or node.data == .index_expr) {
return try self.genAddressOf(node);
}
// Other non-identifier expressions: copy into temp alloca
if (node.data != .identifier) {
const val = try self.genExpr(node);
const llvm_ty = c.LLVMTypeOf(val);
@@ -10459,8 +10462,8 @@ pub const CodeGen = struct {
null;
const i64_type = self.i64Type();
// Enum/union case constants use the backing type; bool uses i1; others use i64
const case_int_type = if (enum_name) |en| self.getEnumLLVMType(en) else if (union_name) |un| self.getEnumLLVMType(un) else if (subject_ty == .boolean) self.i1Type() else i64_type;
// Enum/union case constants use the backing type; bool uses i1; others must match subject LLVM type
const case_int_type = if (enum_name) |en| self.getEnumLLVMType(en) else if (union_name) |un| self.getEnumLLVMType(un) else if (subject_ty == .boolean) self.i1Type() else c.LLVMTypeOf(subject_val);
const merge_bb = self.appendBB("match_end");
// Create case basic blocks