Make param mutable based on type

This commit is contained in:
Sofia 2025-07-21 10:22:57 +03:00
parent 60818842a5
commit b9f6f2ba0f
3 changed files with 5 additions and 5 deletions

View File

@ -367,7 +367,7 @@ impl mir::Module {
stack_values.insert(
p_name.clone(),
StackValue(
StackValueKind::Mutable(alloca),
StackValueKind::mutable(p_ty.is_mutable(), alloca),
TypeKind::Ptr(Box::new(p_ty.clone())),
),
);

View File

@ -75,8 +75,8 @@ impl TypeKind {
pub fn is_mutable(&self) -> bool {
match self {
TypeKind::Borrow(_, true) => true,
_ => false,
TypeKind::Borrow(_, false) => false,
_ => true,
}
}
}

View File

@ -161,8 +161,8 @@ impl FunctionDefinition {
.set(
param.0.clone(),
ScopeVariable {
ty: param_t,
mutable: true,
ty: param_t.clone(),
mutable: param_t.is_mutable(),
},
)
.or(Err(ErrorKind::VariableAlreadyDefined(param.0.clone())));