nac3core: improve some type annotation error messages (#87)

This commit is contained in:
ychenfo 2021-12-27 23:21:42 +08:00 committed by Gitea
parent 9b3b47ce50
commit 85e06d431a

View File

@ -93,12 +93,13 @@ pub fn parse_ast_to_type_annotation_kinds<T>(
Ok(TypeAnnotation::TypeVar(ty))
} else {
Err(format!(
"not a type variable identifier at {}",
"`{}` is not a valid type annotation (at {})",
id,
expr.location
))
}
} else {
Err(format!("name cannot be parsed as a type annotation at {}", expr.location))
Err(format!("`{}` is not a valid type annotation (at {})", id, expr.location))
}
};
@ -244,11 +245,11 @@ pub fn parse_ast_to_type_annotation_kinds<T>(
if let ast::ExprKind::Name { id, .. } = &value.node {
class_name_handle(id, slice, unifier, locked)
} else {
Err(format!("unsupported expression type for class name at {}", value.location))
Err(format!("unsupported expression type for class name (at {})", value.location))
}
}
_ => Err(format!("unsupported expression for type annotation at {}", expr.location)),
_ => Err(format!("unsupported expression for type annotation (at {})", expr.location)),
}
}