mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
6b5c746146
commit
8693da4d36
@ -2556,15 +2556,23 @@ pub fn (mut p Parser) name_expr() ast.Expr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if p.peek_tok.kind == .lpar || is_generic_call || is_generic_cast
|
} else if p.peek_tok.kind == .lpar || is_generic_call || is_generic_cast
|
||||||
|| (p.tok.kind == .lsbr && p.peek_tok.kind == .rsbr && p.peek_token(3).kind == .lpar)
|
|| (p.tok.kind == .lsbr && p.peek_tok.kind == .rsbr && (p.peek_token(3).kind == .lpar
|
||||||
|| (p.tok.kind == .lsbr && p.peek_tok.kind == .number && p.peek_token(2).kind == .rsbr
|
|| p.peek_token(5).kind == .lpar)) || (p.tok.kind == .lsbr && p.peek_tok.kind == .number
|
||||||
&& p.peek_token(4).kind == .lpar) {
|
&& p.peek_token(2).kind == .rsbr && (p.peek_token(4).kind == .lpar
|
||||||
|
|| p.peek_token(6).kind == .lpar)) {
|
||||||
// ?[]foo(), ?[1]foo, foo(), foo<int>() or type() cast
|
// ?[]foo(), ?[1]foo, foo(), foo<int>() or type() cast
|
||||||
mut name := if is_array {
|
mut name := if is_array {
|
||||||
p.peek_token(if is_fixed_array { 3 } else { 2 }).lit
|
p.peek_token(if is_fixed_array { 3 } else { 2 }).lit
|
||||||
} else {
|
} else {
|
||||||
p.tok.lit
|
p.tok.lit
|
||||||
}
|
}
|
||||||
|
if is_fixed_array && p.peek_token(4).kind == .dot {
|
||||||
|
mod = name
|
||||||
|
name = p.peek_token(5).lit
|
||||||
|
} else if is_array && p.peek_token(3).kind == .dot {
|
||||||
|
mod = name
|
||||||
|
name = p.peek_token(4).lit
|
||||||
|
}
|
||||||
if mod.len > 0 {
|
if mod.len > 0 {
|
||||||
name = '${mod}.${name}'
|
name = '${mod}.${name}'
|
||||||
}
|
}
|
||||||
|
@ -8,4 +8,12 @@ fn test_submodule_array_instance() {
|
|||||||
y := ?amodule.SomeStruct(none)
|
y := ?amodule.SomeStruct(none)
|
||||||
dump(y)
|
dump(y)
|
||||||
assert y == none
|
assert y == none
|
||||||
|
|
||||||
|
w := ?[]amodule.SomeStruct(none)
|
||||||
|
dump(w)
|
||||||
|
assert w == none
|
||||||
|
|
||||||
|
z := ?[2]amodule.SomeStruct(none)
|
||||||
|
dump(z)
|
||||||
|
assert z == none
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user