diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2025-07-05 22:42:59 +0200 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2025-07-05 22:42:59 +0200 |
| commit | 172a2d4a8896709bca662f9804ba321010997d75 (patch) | |
| tree | ca5bd9d6eaf0d6881f439be8ce34fdad3c97fec5 /src | |
| parent | 09b1c91170d9e011316fa93dc7e98069dcdc6625 (diff) | |
Fix issue with comp literals and zero fields in return stmt.
Diffstat (limited to 'src')
| -rw-r--r-- | src/odin/printer/visit.odin | 28 |
1 files changed, 16 insertions, 12 deletions
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: |