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( stack_values.insert(
p_name.clone(), p_name.clone(),
StackValue( StackValue(
StackValueKind::Mutable(alloca), StackValueKind::mutable(p_ty.is_mutable(), alloca),
TypeKind::Ptr(Box::new(p_ty.clone())), TypeKind::Ptr(Box::new(p_ty.clone())),
), ),
); );

View File

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

View File

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