diff --git a/reid/src/codegen.rs b/reid/src/codegen.rs index 29d0bd1..1abfbdc 100644 --- a/reid/src/codegen.rs +++ b/reid/src/codegen.rs @@ -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())), ), ); diff --git a/reid/src/mir/impl.rs b/reid/src/mir/impl.rs index 8e22a07..503b1c7 100644 --- a/reid/src/mir/impl.rs +++ b/reid/src/mir/impl.rs @@ -75,8 +75,8 @@ impl TypeKind { pub fn is_mutable(&self) -> bool { match self { - TypeKind::Borrow(_, true) => true, - _ => false, + TypeKind::Borrow(_, false) => false, + _ => true, } } } diff --git a/reid/src/mir/typecheck.rs b/reid/src/mir/typecheck.rs index d438205..77e83fb 100644 --- a/reid/src/mir/typecheck.rs +++ b/reid/src/mir/typecheck.rs @@ -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())));