diff --git a/vlib/v/parser/assign.v b/vlib/v/parser/assign.v index b758e330af..d5f52fc5e3 100644 --- a/vlib/v/parser/assign.v +++ b/vlib/v/parser/assign.v @@ -226,6 +226,11 @@ fn (mut p Parser) partial_assign_stmt(left []ast.Expr) ast.Stmt { pos: lx.pos is_stack_obj: p.inside_for } + if p.prev_tok.kind == .string { + v.typ = ast.string_type_idx + } else if p.prev_tok.kind == .rsbr { + v.typ = ast.array_type_idx + } if p.pref.autofree { r0 := right[0] if r0 is ast.CallExpr { diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 0fa5abe60a..066db7312a 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -2288,6 +2288,21 @@ fn (mut p Parser) ident(language ast.Language) ast.Ident { // `generic_fn[int]` concrete_types = p.parse_concrete_types() } + typ := match p.peek_tok.kind { + .string { + ast.string_type_idx + } + .lsbr { + ast.array_type_idx + } + else { + if p.tok.kind == .dot { + if var := p.scope.find_var(name) { var.typ } else { 0 } + } else { + 0 + } + } + } return ast.Ident{ tok_kind: p.tok.kind kind: .unresolved @@ -2299,6 +2314,7 @@ fn (mut p Parser) ident(language ast.Language) ast.Ident { is_mut: is_mut mut_pos: mut_pos info: ast.IdentVar{ + typ: typ is_mut: is_mut is_static: is_static is_volatile: is_volatile