From e8b21b424233c5da60da18bfd9b274e3ce653b3e Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 19 Jun 2020 12:53:53 +0200 Subject: [PATCH] checker: type `x` does not support indexing --- vlib/v/checker/checker.v | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 15a73fe136..7474a02049 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -2428,6 +2428,10 @@ pub fn (mut c Checker) index_expr(mut node ast.IndexExpr) table.Type { else {} } typ_sym := c.table.get_type_symbol(typ) + if typ_sym.kind !in [.array, .array_fixed, .string, .map] && !typ.is_ptr() && !(!typ_sym.name[0].is_capital() && + typ_sym.name.ends_with('ptr')) && !typ.has_flag(.variadic) { // byteptr, charptr etc + c.error('type `$typ_sym.name` does not support indexing', node.pos) + } if !is_range { index_type := c.expr(node.index) index_type_sym := c.table.get_type_symbol(index_type)