diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 00da395549..b70a43fe87 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -1710,7 +1710,7 @@ pub fn (mut p Parser) parse_ident(language table.Language) ast.Ident { } fn (p &Parser) is_typename(t token.Token) bool { - return t.kind == .name && (t.lit.is_capital() || p.table.known_type(t.lit)) + return t.kind == .name && (t.lit[0].is_capital() || p.table.known_type(t.lit)) } // heuristics to detect `func()` from `var < expr` diff --git a/vlib/v/tests/generic_fn_upper_name_type_test.v b/vlib/v/tests/generic_fn_upper_name_type_test.v new file mode 100644 index 0000000000..77952e9733 --- /dev/null +++ b/vlib/v/tests/generic_fn_upper_name_type_test.v @@ -0,0 +1,18 @@ +struct XX { + x int +} + +struct YY { + y int +} + +fn show_result(x T, y U) bool { + return true +} + +fn test_generic_fn_upper_name_type() { + assert show_result(1, false) + assert show_result( "s", XX{}) + assert show_result< XX, string>(XX{}, "s") + assert show_result< XX, YY>(XX{}, YY{}) +}