Fix needed parentheses under trace-if-false disappearing when formatting.
This commit is contained in:
parent
b6d99142f9
commit
0c0369ad61
|
@ -11,6 +11,7 @@
|
|||
- **aiken-lang**: Fix underflow in error message reported by the validator arity. See [#1013](https://github.com/aiken-lang/aiken/issues/1013) @KtorZ
|
||||
- **aiken-lang**: Fix list-pattern needlessly formatting over multiple lines. @KtorZ
|
||||
- **aiken-lang**: Fix formatter on long alternative patterns spanning over multiple lines. @KtorZ
|
||||
- **aiken-lang**: Fix needed parentheses under trace-if-false operator for todo, fail, unop & pipelines; removed when formatting. @KtorZ
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
@ -2028,7 +2028,17 @@ impl<'comments> Formatter<'comments> {
|
|||
|
||||
fn wrap_unary_op<'a>(&mut self, expr: &'a UntypedExpr) -> Document<'a> {
|
||||
match expr {
|
||||
UntypedExpr::BinOp { .. } => "(".to_doc().append(self.expr(expr, false)).append(")"),
|
||||
UntypedExpr::Trace {
|
||||
kind: TraceKind::Error,
|
||||
..
|
||||
}
|
||||
| UntypedExpr::Trace {
|
||||
kind: TraceKind::Todo,
|
||||
..
|
||||
}
|
||||
| UntypedExpr::PipeLine { .. }
|
||||
| UntypedExpr::BinOp { .. }
|
||||
| UntypedExpr::UnOp { .. } => "(".to_doc().append(self.expr(expr, false)).append(")"),
|
||||
_ => self.wrap_expr(expr),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1296,3 +1296,47 @@ fn multiline_alternative_patterns() {
|
|||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trace_if_false_pipeline() {
|
||||
assert_format!(
|
||||
r#"
|
||||
fn main(self) {
|
||||
(self.extra_signatories |> list.has(self.extra_signatories, config.cold_key))?
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trace_if_false_unop() {
|
||||
assert_format!(
|
||||
r#"
|
||||
fn main(self) {
|
||||
(!True)?
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trace_if_false_todo() {
|
||||
assert_format!(
|
||||
r#"
|
||||
fn main(self) {
|
||||
(todo @"whatever")?
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trace_if_false_fail() {
|
||||
assert_format!(
|
||||
r#"
|
||||
fn main(self) {
|
||||
(fail @"whatever")?
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/format.rs
|
||||
description: "Code:\n\nfn main(self) {\n (fail @\"whatever\")?\n}\n"
|
||||
---
|
||||
fn main(self) {
|
||||
(fail @"whatever")?
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/format.rs
|
||||
description: "Code:\n\nfn main(self) {\n (self.extra_signatories |> list.has(self.extra_signatories, config.cold_key))?\n}\n"
|
||||
---
|
||||
fn main(self) {
|
||||
(self.extra_signatories |> list.has(self.extra_signatories, config.cold_key))?
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/format.rs
|
||||
description: "Code:\n\nfn main(self) {\n (todo @\"whatever\")?\n}\n"
|
||||
---
|
||||
fn main(self) {
|
||||
(todo @"whatever")?
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/format.rs
|
||||
description: "Code:\n\nfn main(self) {\n (!True)?\n}\n"
|
||||
---
|
||||
fn main(self) {
|
||||
(!True)?
|
||||
}
|
Loading…
Reference in New Issue