Fix structs loading values prematurely

This commit is contained in:
Sofia 2025-07-20 20:00:34 +03:00
parent be76331a47
commit 158ddc58c8

View File

@ -685,7 +685,6 @@ impl mir::Expression {
.unwrap() .unwrap()
.maybe_location(&mut scope.block, location); .maybe_location(&mut scope.block, location);
dbg!(&array_ty);
let TypeKind::Ptr(inner) = array_ty else { let TypeKind::Ptr(inner) = array_ty else {
panic!(); panic!();
}; };
@ -771,7 +770,7 @@ impl mir::Expression {
)) ))
} }
mir::ExprKind::Accessed(expression, type_kind, field) => { mir::ExprKind::Accessed(expression, type_kind, field) => {
let struct_val = expression.codegen(scope, state).unwrap(); let struct_val = expression.codegen(scope, &state.load(false)).unwrap();
let TypeKind::Ptr(inner) = &struct_val.1 else { let TypeKind::Ptr(inner) = &struct_val.1 else {
panic!("tried accessing non-pointer"); panic!("tried accessing non-pointer");