From 172a2d4a8896709bca662f9804ba321010997d75 Mon Sep 17 00:00:00 2001 From: DanielGavin Date: Sat, 5 Jul 2025 22:42:59 +0200 Subject: Fix issue with comp literals and zero fields in return stmt. --- src/odin/printer/visit.odin | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index 13d9a17..0f3f691 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -1830,19 +1830,23 @@ visit_expr :: proc( document = cons(document, nest(inner_document), newline(1), text_position(p, "}", v.end)) } else { break_string := " " if v.type != nil else "" - document = cons( - document, - group( - cons( - if_break(break_string), - text("{"), - nest(cons(break_with(""), visit_exprs(p, v.elems, {.Add_Comma, .Group}))), - if_break(","), - break_with(""), - text("}"), + if len(v.elems) > 0 { + document = cons( + document, + group( + cons( + if_break(break_string), + text("{"), + nest(cons(break_with(""), visit_exprs(p, v.elems, {.Add_Comma, .Group}))), + if_break(","), + break_with(""), + text("}"), + ), ), - ), - ) + ) + } else { + document = cons(document, cons(text("{"), text("}"))) + } document = group(document) } case ^Unary_Expr: -- cgit v1.2.3