From 85e06d431aed8eb114abba3beb80e886c7e1c6a2 Mon Sep 17 00:00:00 2001 From: ychenfo Date: Mon, 27 Dec 2021 23:21:42 +0800 Subject: [PATCH] nac3core: improve some type annotation error messages (#87) --- nac3core/src/toplevel/type_annotation.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nac3core/src/toplevel/type_annotation.rs b/nac3core/src/toplevel/type_annotation.rs index 3c4a99486..3cbc85ccd 100644 --- a/nac3core/src/toplevel/type_annotation.rs +++ b/nac3core/src/toplevel/type_annotation.rs @@ -93,12 +93,13 @@ pub fn parse_ast_to_type_annotation_kinds( 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( 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)), } }