diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 26ec2e3f25..f7122bb45f 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -3674,8 +3674,8 @@ fn (mut p Parser) type_decl() ast.TypeDecl { } name := p.check_name() if name.len == 1 && name[0].is_capital() { - p.error_with_pos('single letter capital names are reserved for generic template types.', - decl_pos) + p.error_with_pos('single letter capital names are reserved for generic template types', + name_pos) return ast.FnTypeDecl{} } if name in p.imported_symbols { diff --git a/vlib/v/parser/tests/type_decl_name_err.out b/vlib/v/parser/tests/type_decl_name_err.out new file mode 100644 index 0000000000..b74c638e44 --- /dev/null +++ b/vlib/v/parser/tests/type_decl_name_err.out @@ -0,0 +1,5 @@ +vlib/v/parser/tests/type_decl_name_err.vv:1:6: error: single letter capital names are reserved for generic template types + 1 | type A = int | string + | ^ + 2 | + 3 | fn main() { diff --git a/vlib/v/parser/tests/type_decl_name_err.vv b/vlib/v/parser/tests/type_decl_name_err.vv new file mode 100644 index 0000000000..cc2faddb24 --- /dev/null +++ b/vlib/v/parser/tests/type_decl_name_err.vv @@ -0,0 +1,6 @@ +type A = int | string + +fn main() { + a := A(11) + println(a) +}