feat: prefix tuples with hash again cause ambguity with call
This commit is contained in:
parent
6dc4738b66
commit
69db9696d6
|
@ -377,9 +377,12 @@ impl<'comments> Formatter<'comments> {
|
|||
..
|
||||
} => docvec![module, ".", name],
|
||||
|
||||
Constant::Tuple { elements, .. } => {
|
||||
wrap_args(elements.iter().map(|e| (self.const_expr(e), false))).group()
|
||||
}
|
||||
Constant::Tuple { elements, .. } => "#"
|
||||
.to_doc()
|
||||
.append(wrap_args(
|
||||
elements.iter().map(|e| (self.const_expr(e), false)),
|
||||
))
|
||||
.group(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -462,9 +465,9 @@ impl<'comments> Formatter<'comments> {
|
|||
.append(break_("", " ").append(self.annotation(retrn)).nest(INDENT)),
|
||||
|
||||
Annotation::Var { name, .. } => name.to_doc(),
|
||||
Annotation::Tuple { elems, .. } => {
|
||||
wrap_args(elems.iter().map(|t| (self.annotation(t), false)))
|
||||
}
|
||||
Annotation::Tuple { elems, .. } => "#"
|
||||
.to_doc()
|
||||
.append(wrap_args(elems.iter().map(|t| (self.annotation(t), false)))),
|
||||
}
|
||||
.group()
|
||||
}
|
||||
|
@ -783,9 +786,10 @@ impl<'comments> Formatter<'comments> {
|
|||
..
|
||||
} => self.record_update(constructor, spread, args),
|
||||
|
||||
UntypedExpr::Tuple { elems, .. } => {
|
||||
wrap_args(elems.iter().map(|e| (self.wrap_expr(e), false))).group()
|
||||
}
|
||||
UntypedExpr::Tuple { elems, .. } => "#"
|
||||
.to_doc()
|
||||
.append(wrap_args(elems.iter().map(|e| (self.wrap_expr(e), false))))
|
||||
.group(),
|
||||
};
|
||||
commented(document, comments)
|
||||
}
|
||||
|
@ -1349,9 +1353,10 @@ impl<'comments> Formatter<'comments> {
|
|||
|
||||
Pattern::Discard { name, .. } => name.to_doc(),
|
||||
|
||||
Pattern::Tuple { elems, .. } => {
|
||||
wrap_args(elems.iter().map(|e| (self.pattern(e), false))).group()
|
||||
}
|
||||
Pattern::Tuple { elems, .. } => "#"
|
||||
.to_doc()
|
||||
.append(wrap_args(elems.iter().map(|e| (self.pattern(e), false))))
|
||||
.group(),
|
||||
|
||||
Pattern::List { elements, tail, .. } => {
|
||||
let elements_document =
|
||||
|
|
|
@ -336,11 +336,13 @@ fn constant_value_parser() -> impl Parser<Token, ast::UntypedConstant, Error = P
|
|||
}
|
||||
});
|
||||
|
||||
let constant_tuple_parser = r
|
||||
.clone()
|
||||
.separated_by(just(Token::Comma))
|
||||
.allow_trailing()
|
||||
.delimited_by(just(Token::LeftParen), just(Token::RightParen))
|
||||
let constant_tuple_parser = just(Token::Hash)
|
||||
.ignore_then(
|
||||
r.clone()
|
||||
.separated_by(just(Token::Comma))
|
||||
.allow_trailing()
|
||||
.delimited_by(just(Token::LeftParen), just(Token::RightParen)),
|
||||
)
|
||||
.map_with_span(|elements, span| ast::UntypedConstant::Tuple {
|
||||
location: span,
|
||||
elements,
|
||||
|
@ -849,11 +851,13 @@ pub fn expr_parser(
|
|||
label,
|
||||
});
|
||||
|
||||
let tuple = r
|
||||
.clone()
|
||||
.separated_by(just(Token::Comma))
|
||||
.allow_trailing()
|
||||
.delimited_by(just(Token::LeftParen), just(Token::RightParen))
|
||||
let tuple = just(Token::Hash)
|
||||
.ignore_then(
|
||||
r.clone()
|
||||
.separated_by(just(Token::Comma))
|
||||
.allow_trailing()
|
||||
.delimited_by(just(Token::LeftParen), just(Token::RightParen)),
|
||||
)
|
||||
.map_with_span(|elems, span| expr::UntypedExpr::Tuple {
|
||||
location: span,
|
||||
elems,
|
||||
|
@ -1298,10 +1302,13 @@ pub fn type_parser() -> impl Parser<Token, ast::Annotation, Error = ParseError>
|
|||
}
|
||||
}),
|
||||
// Tuple
|
||||
r.clone()
|
||||
.separated_by(just(Token::Comma))
|
||||
.allow_trailing()
|
||||
.delimited_by(just(Token::LeftParen), just(Token::RightParen))
|
||||
just(Token::Hash)
|
||||
.ignore_then(
|
||||
r.clone()
|
||||
.separated_by(just(Token::Comma))
|
||||
.allow_trailing()
|
||||
.delimited_by(just(Token::LeftParen), just(Token::RightParen)),
|
||||
)
|
||||
.map_with_span(|elems, span| ast::Annotation::Tuple {
|
||||
location: span,
|
||||
elems,
|
||||
|
@ -1522,10 +1529,13 @@ pub fn pattern_parser() -> impl Parser<Token, ast::UntypedPattern, Error = Parse
|
|||
value,
|
||||
}
|
||||
}),
|
||||
r.clone()
|
||||
.separated_by(just(Token::Comma))
|
||||
.allow_trailing()
|
||||
.delimited_by(just(Token::LeftParen), just(Token::RightParen))
|
||||
just(Token::Hash)
|
||||
.ignore_then(
|
||||
r.clone()
|
||||
.separated_by(just(Token::Comma))
|
||||
.allow_trailing()
|
||||
.delimited_by(just(Token::LeftParen), just(Token::RightParen)),
|
||||
)
|
||||
.map_with_span(|elems, span| ast::UntypedPattern::Tuple {
|
||||
location: span,
|
||||
elems,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use sample
|
||||
|
||||
pub fn spend(datum: sample.Datum, rdmr: sample.Redeemer, _ctx: Nil) -> Bool {
|
||||
let x = (datum, rdmr, #[244])
|
||||
let y = [(#[222], #[222]), (#[233], #[52])]
|
||||
let x = #(datum, rdmr, #[244])
|
||||
let y = [#(#[222], #[222]), #(#[233], #[52])]
|
||||
let [z, f, ..g] = y
|
||||
let (a, b, _) = x
|
||||
z == (#[222], #[222])
|
||||
let #(a, b, _) = x
|
||||
z == #(#[222], #[222])
|
||||
}
|
||||
|
||||
test foo() {
|
||||
|
|
Loading…
Reference in New Issue