Fix casting to same type

This commit is contained in:
Sofia 2025-07-22 14:21:17 +03:00
parent e27aa4b8ab
commit 9c0d373f9d

View File

@ -1030,9 +1030,10 @@ impl mir::Expression {
}
mir::ExprKind::CastTo(expression, type_kind) => {
let val = expression.codegen(scope, state)?;
let instr =
if let (TypeKind::UserPtr(_), TypeKind::UserPtr(_)) = (&val.1, type_kind) {
val.0.instr()
if val.1 == *type_kind {
Some(val)
} else if let (TypeKind::UserPtr(_), TypeKind::UserPtr(_)) = (&val.1, type_kind) {
Some(val)
} else {
let cast_instr = val
.1
@ -1042,10 +1043,12 @@ impl mir::Expression {
&type_kind.get_type(scope.type_values, scope.types),
)
.unwrap();
scope.block.build(cast_instr).unwrap()
};
Some(StackValue(val.0.derive(instr), type_kind.clone()))
Some(StackValue(
val.0.derive(scope.block.build(cast_instr).unwrap()),
type_kind.clone(),
))
}
}
};
if let Some(value) = &value {