Browse Source

Fix printing error when field name could not be found

gingerBill 1 year ago
parent
commit
114ddc4a10
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/check_expr.cpp

+ 2 - 1
src/check_expr.cpp

@@ -4595,7 +4595,8 @@ gb_internal ExactValue get_constant_field_single(CheckerContext *c, ExactValue v
 					String name = fv->field->Ident.token.string;
 					Selection sub_sel = lookup_field(node->tav.type, name, false);
 					defer (array_free(&sub_sel.index));
-					if (sub_sel.index[0] == index) {
+					if (sub_sel.index.count > 0 &&
+					    sub_sel.index[0] == index) {
 						value = fv->value->tav.value;
 						found = true;
 						break;