From 25ba6ea459d0167af0c366e7a7a97da386c27751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Wed, 9 Jun 2021 01:06:44 +0300 Subject: [PATCH] Def cleanup (#3580) * Remove impossible condition * Improve def error * Fmt --- crates/nu-parser/src/parse/def.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/nu-parser/src/parse/def.rs b/crates/nu-parser/src/parse/def.rs index 70c27d903..06151c66d 100644 --- a/crates/nu-parser/src/parse/def.rs +++ b/crates/nu-parser/src/parse/def.rs @@ -29,10 +29,6 @@ pub(crate) fn parse_definition(call: &LiteCommand, scope: &dyn ParserScope) -> O // prototypes of adjacent commands are also available if call.parts.len() == 4 { - if call.parts.len() != 4 { - return Some(ParseError::mismatch("definition", call.parts[0].clone())); - } - if call.parts[0].item != "def" { return Some(ParseError::mismatch("definition", call.parts[0].clone())); } @@ -81,7 +77,9 @@ pub(crate) fn parse_definition(call: &LiteCommand, scope: &dyn ParserScope) -> O } } else { Some(ParseError::internal_error( - "need a block".to_string().spanned(call.span()), + "Wrong shape. Expected def name [signature] {body}." + .to_string() + .spanned(call.span()), )) } }