diff --git a/crates/lang/src/parser.rs b/crates/lang/src/parser.rs index 67336d66..89c2ed47 100644 --- a/crates/lang/src/parser.rs +++ b/crates/lang/src/parser.rs @@ -1061,19 +1061,40 @@ pub fn pattern_parser() -> impl Parser Some(pat), + Some(Some(pat)) => { + // use emit + // return parse_error(ParseErrorType::InvalidTailPattern, pat.location()) + Some(pat) + } + // There is a tail but it has no content, implicit discard + Some(None) => Some(ast::UntypedPattern::Discard { + location: Span { + start: span.end - 1, + end: span.end, + }, + name: "_".to_string(), + }), + // No tail specified + None => None, + }; + + ast::UntypedPattern::List { + location: span, + elements, + tail: tail.map(Box::new), + } }), )) .then(