[fine] Error checking for some cases
This commit is contained in:
parent
4505996710
commit
d0b74db715
2 changed files with 33 additions and 2 deletions
|
|
@ -1375,7 +1375,14 @@ impl<'a> Semantics<'a> {
|
|||
// Form 2: { x, ... }
|
||||
let environment = self.environment_of(t);
|
||||
let id = tree.nth_token(0)?;
|
||||
match environment.bind(id)? {
|
||||
let declaration = match environment.bind(id) {
|
||||
Some(d) => d,
|
||||
None => {
|
||||
self.report_error_tree(tree, format!("cannot find value {id} here"));
|
||||
return Some(Type::Error);
|
||||
}
|
||||
};
|
||||
match declaration {
|
||||
Declaration::Variable {
|
||||
declaration_type, ..
|
||||
}
|
||||
|
|
@ -1662,7 +1669,7 @@ fn check_new_object_expression(s: &Semantics, tree: &Tree) {
|
|||
s.report_error_tree_ref(
|
||||
*field_tree,
|
||||
format!(
|
||||
"field {} has is of type {}, but this expression generates a {}",
|
||||
"field {} is of type {}, but this expression generates a {}",
|
||||
f.name, f.field_type, expr_type,
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue