From 24b2111c6416a1111c050a17b492d4ee01638055 Mon Sep 17 00:00:00 2001 From: ychenfo Date: Sun, 3 Oct 2021 17:22:06 +0800 Subject: [PATCH] nac3core: fix #45 toplevel better error msg for methods/functions --- nac3core/src/toplevel/composer.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/nac3core/src/toplevel/composer.rs b/nac3core/src/toplevel/composer.rs index f7c08337..c3197762 100644 --- a/nac3core/src/toplevel/composer.rs +++ b/nac3core/src/toplevel/composer.rs @@ -894,9 +894,11 @@ impl TopLevelComposer { .node .annotation .as_ref() - .ok_or_else(|| { - "function parameter type annotation needed".to_string() - })? + .ok_or_else(|| format!( + "function parameter `{}` at {} need type annotation", + x.node.arg, + x.location + ))? .as_ref(); let type_annotation = parse_ast_to_type_annotation_kinds( @@ -1098,7 +1100,11 @@ impl TopLevelComposer { .node .annotation .as_ref() - .ok_or_else(|| "type annotation needed".to_string())? + .ok_or_else(|| format!( + "type annotation for `{}` at {} needed", + x.node.arg, + x.location + ))? .as_ref(); parse_ast_to_type_annotation_kinds( class_resolver.as_ref(),