mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: type x
does not support indexing
This commit is contained in:
parent
5f5228f0f3
commit
e8b21b4242
@ -2428,6 +2428,10 @@ pub fn (mut c Checker) index_expr(mut node ast.IndexExpr) table.Type {
|
|||||||
else {}
|
else {}
|
||||||
}
|
}
|
||||||
typ_sym := c.table.get_type_symbol(typ)
|
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 {
|
if !is_range {
|
||||||
index_type := c.expr(node.index)
|
index_type := c.expr(node.index)
|
||||||
index_type_sym := c.table.get_type_symbol(index_type)
|
index_type_sym := c.table.get_type_symbol(index_type)
|
||||||
|
Loading…
Reference in New Issue
Block a user