mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v.parser: fix generics type name in if_expr (#11156)
This commit is contained in:
parent
e089d66225
commit
89a8854e57
@ -57,7 +57,7 @@ pub fn (mut p Parser) check_expr(precedence int) ?ast.Expr {
|
||||
node = p.map_init()
|
||||
p.check(.rcbr) // `}`
|
||||
} else {
|
||||
if p.inside_if && p.is_generic_name() {
|
||||
if p.inside_if && p.is_generic_name() && p.peek_tok.kind != .dot {
|
||||
// $if T is string {}
|
||||
p.expecting_type = true
|
||||
}
|
||||
|
13
vlib/v/tests/type_name_in_if_test.v
Normal file
13
vlib/v/tests/type_name_in_if_test.v
Normal file
@ -0,0 +1,13 @@
|
||||
struct Flag<T> {}
|
||||
|
||||
fn (f Flag<T>) verify() {
|
||||
if T.name == 'int' {
|
||||
println('It is an int!')
|
||||
assert true
|
||||
}
|
||||
}
|
||||
|
||||
fn test_generic_type_name_in_if() {
|
||||
flag := Flag<int>{}
|
||||
flag.verify()
|
||||
}
|
Loading…
Reference in New Issue
Block a user