v.parser: fix generics type name in if_expr (#11156)
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
|
||||
}
|
||||
|
|
|
@ -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