From 36cc4880a644fe6783c29b806a0ed9cb1377a6f2 Mon Sep 17 00:00:00 2001
From: yuyi <yuyi98@163.com>
Date: Fri, 26 Mar 2021 22:50:35 +0800
Subject: [PATCH] parser: fix generic fn with upper name type (#9460) (#9478)

---
 vlib/v/parser/parser.v                         |  2 +-
 vlib/v/tests/generic_fn_upper_name_type_test.v | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 vlib/v/tests/generic_fn_upper_name_type_test.v

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<T>()` 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<T, U>(x T, y U) bool {
+	return true
+}
+
+fn test_generic_fn_upper_name_type() {
+	assert show_result<int, bool>(1,  false)
+	assert show_result<string, XX>( "s",  XX{})
+	assert show_result< XX, string>(XX{}, "s")
+	assert show_result< XX, YY>(XX{}, YY{})
+}