From f814d3e9791c9ef6dc3c002017f0d949224e6b44 Mon Sep 17 00:00:00 2001 From: DanielGavin Date: Tue, 21 Jun 2022 10:39:17 +0200 Subject: Fix matrix_type only be checked if type is not null --- src/odin/printer/visit.odin | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index f0d718b..9a22c8b 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -1200,18 +1200,21 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, called_from: Expr_Called_Type = if v.type != nil { document = cons_with_nopl(document, visit_expr(p, v.type)) - } - - if matrix_type, ok := v.type.derived.(^ast.Matrix_Type); ok && is_matrix_type_constant(matrix_type) { - document = cons_with_opl(document, visit_begin_brace(p, v.pos, .Generic)) - set_source_position(p, v.open) - document = cons(document, nest(p.indentation_count, cons(newline_position(p, 1, v.elems[0].pos), visit_matrix_comp_lit(p, v, matrix_type)))) - set_source_position(p, v.end) + if matrix_type, ok := v.type.derived.(^ast.Matrix_Type); ok && is_matrix_type_constant(matrix_type) { + document = cons_with_opl(document, visit_begin_brace(p, v.pos, .Generic)) + + set_source_position(p, v.open) + document = cons(document, nest(p.indentation_count, cons(newline_position(p, 1, v.elems[0].pos), visit_matrix_comp_lit(p, v, matrix_type)))) + set_source_position(p, v.end) - document = cons(document, cons(newline(1), text_position(p, "}", v.end))) + document = cons(document, cons(newline(1), text_position(p, "}", v.end))) + + break + } } - else if (should_align_comp_lit(p, v^) || contains_comments_in_range(p, v.pos, v.end)) && (called_from == .Value_Decl || called_from == .Assignment_Stmt) && len(v.elems) != 0 { + + if (should_align_comp_lit(p, v^) || contains_comments_in_range(p, v.pos, v.end)) && (called_from == .Value_Decl || called_from == .Assignment_Stmt) && len(v.elems) != 0 { document = cons_with_opl(document, visit_begin_brace(p, v.pos, .Generic)) set_source_position(p, v.open) -- cgit v1.2.3