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