forked from M-Labs/nac3
1
0
Fork 0

nac3core: composer better error msg in for uninit field

This commit is contained in:
ychenfo 2021-11-12 02:25:53 +08:00
parent aae9925014
commit 01b51b62ee
1 changed files with 8 additions and 5 deletions

View File

@ -1646,9 +1646,11 @@ impl TopLevelComposer {
unreachable!("must be init function here") unreachable!("must be init function here")
} }
let all_inited = Self::get_all_assigned_field(body.as_slice())?; let all_inited = Self::get_all_assigned_field(body.as_slice())?;
if fields.iter().any(|x| !all_inited.contains(&x.0)) { for (f, _, _) in fields {
if !all_inited.contains(f) {
return Err(format!( return Err(format!(
"fields of class {} not fully initialized", "fields `{}` of class `{}` not fully initialized",
f,
class_name class_name
)); ));
} }
@ -1656,6 +1658,7 @@ impl TopLevelComposer {
} }
} }
} }
}
let ctx = Arc::new(self.make_top_level_context()); let ctx = Arc::new(self.make_top_level_context());
// type inference inside function body // type inference inside function body