diff --git a/src/prettyPrinter.ts b/src/prettyPrinter.ts index db8c64c96..6d55bc43c 100644 --- a/src/prettyPrinter.ts +++ b/src/prettyPrinter.ts @@ -380,7 +380,9 @@ const createContext = (spaces: number): Context => { const indent = (rows: readonly ContextModel[]) => block(rows).map((f) => (level: number) => f(level + 1)); const braced = (rows: readonly ContextModel[]) => - block([row(`{`), indent(rows), row(`}`)]); + block( + rows.length > 0 ? [row(`{`), indent(rows), row(`}`)] : [row("{}")], + ); const list = (items: readonly T[], print: Printer) => items.map((node) => print(node)(ctx)); const grouped = ({ @@ -695,7 +697,7 @@ export const ppAstFuncId = (func: A.AstFuncId): string => func.text; // export const ppStatementBlock: Printer = (stmts) => (c) => - c.braced(stmts.length === 0 ? [c.row("")] : c.list(stmts, ppAstStatement)); + c.braced(stmts.length === 0 ? [] : c.list(stmts, ppAstStatement)); export const ppAsmInstructionsBlock: Printer = (instructions) => (c) => diff --git a/src/test/contracts/case-bin-ops.tact b/src/test/contracts/case-bin-ops.tact index 2e4e2cd4d..92232148d 100644 --- a/src/test/contracts/case-bin-ops.tact +++ b/src/test/contracts/case-bin-ops.tact @@ -3,8 +3,6 @@ contract SampleContract { init() { self.a = (1 + 2 - 3) / 4 % 5 | 255 & 53 ^ 2; - if (1 > 2 || 3 == 0 && (5 - 3) * 10 > 0) { - - } + if (1 > 2 || 3 == 0 && (5 - 3) * 10 > 0) {} } -} \ No newline at end of file +} diff --git a/src/test/contracts/case-message-opcode.tact b/src/test/contracts/case-message-opcode.tact index ea696de45..ce4ce5f97 100644 --- a/src/test/contracts/case-message-opcode.tact +++ b/src/test/contracts/case-message-opcode.tact @@ -30,5 +30,4 @@ message(DEADBEEF + 1) MyMessageWithExprOpcode { a: Int; } -contract TestContract { -} +contract TestContract {} diff --git a/src/test/contracts/case-traits.tact b/src/test/contracts/case-traits.tact index 69d07cb5b..ab17eea8f 100644 --- a/src/test/contracts/case-traits.tact +++ b/src/test/contracts/case-traits.tact @@ -1,5 +1,4 @@ -@interface("") trait B { -} +@interface("") trait B {} trait C { abstract get fun d(e: String): String; @@ -12,9 +11,7 @@ trait Ownable with B { const someNum: Int = 2; abstract const something: Int; - receive("message") { - - } + receive("message") {} fun requireOwner() { nativeThrowUnless(132, context().sender == self.owner); @@ -35,4 +32,4 @@ trait Ownable with B { self.owner = owner; self.value = 1; } -} \ No newline at end of file +} diff --git a/src/test/contracts/renamer-expected/case-bin-ops.tact b/src/test/contracts/renamer-expected/case-bin-ops.tact index b720ef96f..a83f27fbf 100644 --- a/src/test/contracts/renamer-expected/case-bin-ops.tact +++ b/src/test/contracts/renamer-expected/case-bin-ops.tact @@ -3,8 +3,6 @@ contract contract_0 { init() { self.a = (1 + 2 - 3) / 4 % 5 | 255 & 53 ^ 2; - if (1 > 2 || 3 == 0 && (5 - 3) * 10 > 0) { - - } + if (1 > 2 || 3 == 0 && (5 - 3) * 10 > 0) {} } } diff --git a/src/test/contracts/renamer-expected/case-message-opcode.tact b/src/test/contracts/renamer-expected/case-message-opcode.tact index 683a72ceb..7c58e2b2f 100644 --- a/src/test/contracts/renamer-expected/case-message-opcode.tact +++ b/src/test/contracts/renamer-expected/case-message-opcode.tact @@ -30,5 +30,4 @@ message(constant_def_5 + 1) message_decl_6 { const constant_def_5: Int = 0xdeadbeef; -contract contract_7 { -} +contract contract_7 {} diff --git a/src/test/contracts/renamer-expected/case-traits.tact b/src/test/contracts/renamer-expected/case-traits.tact index 967178b84..0c7cd47b1 100644 --- a/src/test/contracts/renamer-expected/case-traits.tact +++ b/src/test/contracts/renamer-expected/case-traits.tact @@ -1,5 +1,4 @@ -@interface("") trait trait_0 { -} +@interface("") trait trait_0 {} trait trait_1 { abstract get fun function_decl_2(e: String): String; @@ -12,9 +11,7 @@ trait trait_3 with B { const constant_def_4: Int = 2; abstract const constant_decl_5: Int; - receive("message") { - - } + receive("message") {} fun function_def_6() { nativeThrowUnless(132, context().sender == self.owner);