Fix formatter getting rid of curly braces around multi-line constants.

This commit is contained in:
KtorZ 2024-09-08 16:23:41 +02:00
parent 0c0369ad61
commit 616dec8f03
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
4 changed files with 22 additions and 1 deletions

View File

@ -12,6 +12,7 @@
- **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
- **aiken-lang**: Fix formatter removing curly braces around multi-line constants. It's fine to not have curly braces, but it's the Aiken signature after all. @KtorZ
### Removed

View File

@ -295,7 +295,7 @@ impl<'comments> Formatter<'comments> {
head.append(" =")
.append(break_("", " "))
.append(self.expr(value, true))
.append(self.expr(value, false))
.nest(INDENT)
.group()
}

View File

@ -1340,3 +1340,15 @@ fn trace_if_false_fail() {
"#
);
}
#[test]
fn multiline_constant() {
assert_format!(
r#"
const n: Int = {
let x = 0
x + 1
}
"#
);
}

View File

@ -0,0 +1,8 @@
---
source: crates/aiken-lang/src/tests/format.rs
description: "Code:\n\nconst n: Int = {\n let x = 0\n x + 1\n}\n"
---
const n: Int = {
let x = 0
x + 1
}