mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
parser: parse string and array typ idx of ScopeVar
and Ident
(#21523)
This commit is contained in:
parent
6389da7047
commit
1f7c91e00f
2 changed files with 21 additions and 0 deletions
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue