diff --git a/crates/aiken-lang/src/ast.rs b/crates/aiken-lang/src/ast.rs index 2d59a8c7..2b6f0c9a 100644 --- a/crates/aiken-lang/src/ast.rs +++ b/crates/aiken-lang/src/ast.rs @@ -703,7 +703,7 @@ pub enum Pattern { }, /// A name given to a sub-pattern using the `as` keyword. - /// e.g. `assert #(1, [_, _] as the_list) = x` + /// e.g. `assert (1, [_, _] as the_list) = x` Assign { name: String, location: Span, diff --git a/crates/aiken-lang/src/format.rs b/crates/aiken-lang/src/format.rs index 716a1eff..ca5587d7 100644 --- a/crates/aiken-lang/src/format.rs +++ b/crates/aiken-lang/src/format.rs @@ -396,13 +396,9 @@ impl<'comments> Formatter<'comments> { .. } => docvec![module, ".", name], - Constant::Tuple { elements, .. } => "#" - .to_doc() - .append(wrap_args( - false, - elements.iter().map(|e| (self.const_expr(e), false)), - )) - .group(), + Constant::Tuple { elements, .. } => { + wrap_args(false, elements.iter().map(|e| (self.const_expr(e), false))).group() + } } } @@ -480,10 +476,9 @@ impl<'comments> Formatter<'comments> { .append(break_("", " ").append(self.annotation(retrn)).nest(INDENT)), Annotation::Var { name, .. } => name.to_doc(), - Annotation::Tuple { elems, .. } => "#".to_doc().append(wrap_args( - false, - elems.iter().map(|t| (self.annotation(t), false)), - )), + Annotation::Tuple { elems, .. } => { + wrap_args(false, elems.iter().map(|t| (self.annotation(t), false))) + } } .group() } @@ -768,13 +763,9 @@ impl<'comments> Formatter<'comments> { .. } => self.record_update(constructor, spread, args), - UntypedExpr::Tuple { elems, .. } => "#" - .to_doc() - .append(wrap_args( - false, - elems.iter().map(|e| (self.wrap_expr(e), false)), - )) - .group(), + UntypedExpr::Tuple { elems, .. } => { + wrap_args(false, elems.iter().map(|e| (self.wrap_expr(e), false))).group() + } UntypedExpr::TupleIndex { index, tuple, .. } => { let suffix = Ordinal(*index + 1).suffix().to_doc(); @@ -1500,13 +1491,9 @@ impl<'comments> Formatter<'comments> { Pattern::Discard { name, .. } => name.to_doc(), - Pattern::Tuple { elems, .. } => "#" - .to_doc() - .append(wrap_args( - false, - elems.iter().map(|e| (self.pattern(e), false)), - )) - .group(), + Pattern::Tuple { elems, .. } => { + wrap_args(false, elems.iter().map(|e| (self.pattern(e), false))).group() + } Pattern::List { elements, tail, .. } => { let elements_document = diff --git a/crates/aiken-lang/src/parser.rs b/crates/aiken-lang/src/parser.rs index 4206104f..8eb38b3a 100644 --- a/crates/aiken-lang/src/parser.rs +++ b/crates/aiken-lang/src/parser.rs @@ -346,12 +346,14 @@ fn constant_value_parser() -> impl Parser impl Parser } }), // Tuple - just(Token::Hash) - .ignore_then( - r.clone() - .separated_by(just(Token::Comma)) - .allow_trailing() - .delimited_by(just(Token::LeftParen), just(Token::RightParen)), - ) + r.clone() + .separated_by(just(Token::Comma)) + .at_least(2) + .allow_trailing() + .delimited_by(just(Token::LeftParen), just(Token::RightParen)) .map_with_span(|elems, span| ast::Annotation::Tuple { location: span, elems, @@ -1607,13 +1609,10 @@ pub fn pattern_parser() -> impl Parser self.type_var_doc(&typ.borrow()), - Type::Tuple { elems, .. } => self.args_to_aiken_doc(elems).surround("#(", ")"), + Type::Tuple { elems, .. } => self.args_to_aiken_doc(elems).surround("(", ")"), } }