aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2022-06-21 10:39:17 +0200
committerGitHub <noreply@github.com>2022-06-21 10:39:17 +0200
commitf814d3e9791c9ef6dc3c002017f0d949224e6b44 (patch)
treed574e43b9d73be8e79fb6baf9f0c9323aecbbb86
parent002e6d4903d35da3b577e2b26aa3c0bc66c86fa3 (diff)
Fix matrix_type only be checked if type is not null
-rw-r--r--src/odin/printer/visit.odin21
1 files 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)