Forbid accessing to a mut object in a func

This commit is contained in:
Shunsuke Shibayama 2022-12-01 23:11:42 +09:00
parent 9b1457b695
commit afad52c449
3 changed files with 35 additions and 0 deletions

View file

@ -374,6 +374,16 @@ impl SideEffectChecker {
Expr::TypeAsc(type_asc) => {
self.check_expr(&type_asc.expr);
}
Expr::Accessor(acc) => {
if !self.in_context_effects_allowed() && acc.ref_t().is_mut_type() {
self.errs.push(EffectError::touch_mut_error(
self.cfg.input.clone(),
line!() as usize,
expr,
self.full_path(),
));
}
}
_ => {}
}
}