nac3core: fix #45 toplevel better error msg for methods/functions

This commit is contained in:
ychenfo 2021-10-03 17:22:06 +08:00
parent f5ce1afe0b
commit 24b2111c64
1 changed files with 10 additions and 4 deletions

View File

@ -894,9 +894,11 @@ impl TopLevelComposer {
.node .node
.annotation .annotation
.as_ref() .as_ref()
.ok_or_else(|| { .ok_or_else(|| format!(
"function parameter type annotation needed".to_string() "function parameter `{}` at {} need type annotation",
})? x.node.arg,
x.location
))?
.as_ref(); .as_ref();
let type_annotation = parse_ast_to_type_annotation_kinds( let type_annotation = parse_ast_to_type_annotation_kinds(
@ -1098,7 +1100,11 @@ impl TopLevelComposer {
.node .node
.annotation .annotation
.as_ref() .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(); .as_ref();
parse_ast_to_type_annotation_kinds( parse_ast_to_type_annotation_kinds(
class_resolver.as_ref(), class_resolver.as_ref(),