From 0302cd69bdc30db8d7030d14fc1b571827b615aa Mon Sep 17 00:00:00 2001 From: playX Date: Tue, 26 Apr 2022 09:15:35 +0000 Subject: [PATCH] checker: allow indexing through alias to int (#14177) --- vlib/v/checker/checker.v | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 85dfa2a17a..b8a3a98444 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -3775,7 +3775,9 @@ fn (mut c Checker) check_index(typ_sym &ast.TypeSymbol, index ast.Expr, index_ty // if typ_sym.kind == .array && (!(ast.type_idx(index_type) in ast.number_type_idxs) && // index_type_sym.kind != .enum_) { if typ_sym.kind in [.array, .array_fixed, .string] { - if !(index_type.is_int() || index_type_sym.kind == .enum_) { + if !(index_type.is_int() || index_type_sym.kind == .enum_ + || (index_type_sym.kind == .alias + && (index_type_sym.info as ast.Alias).parent_type.is_int())) { type_str := if typ_sym.kind == .string { 'non-integer string index `$index_type_sym.name`' } else {