diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 94c352ae6c..6c42bee9e7 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -1694,7 +1694,7 @@ fn (p &Parser) is_typename(t token.Token) bool { // heuristics to detect `func()` from `var < expr` // 1. `f<[]` is generic(e.g. `f<[]int>`) because `var < []` is invalid // 2. `f) -// 3. `f` is generic because `v1 < foo > v2` is invalid syntax +// 3. `f` and `f v2` and `v1 < foo < v2` are invalid syntax // 4. `f` is same as case 3 @@ -1727,7 +1727,7 @@ fn (p &Parser) is_generic_call() bool { return true } return match kind3 { - .gt { true } // case 3 + .gt, .lt { true } // case 3 .comma { p.is_typename(tok2) } // case 4 // case 5 and 6 .dot { kind4 == .name && (kind5 == .gt || (kind5 == .comma && p.is_typename(tok4))) } diff --git a/vlib/v/tests/generics_test.v b/vlib/v/tests/generics_test.v index f0870d6be0..fa4d629dd9 100644 --- a/vlib/v/tests/generics_test.v +++ b/vlib/v/tests/generics_test.v @@ -437,6 +437,8 @@ fn test_generic_detection() { // generic assert multi_generic_args(0, 's') assert multi_generic_args(Foo1{}, Foo2{}) + assert multi_generic_args, Foo >(Foo{}, Foo{}) + // TODO: assert multi_generic_args, Foo>(Foo1{}, Foo2{}) assert multi_generic_args(simplemodule.Data{}, 0) assert multi_generic_args(0, simplemodule.Data{}) assert multi_generic_args<[]int, int>([]int{}, 0)