1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: fix the incorrect location of the type declaration name (#14879)

This commit is contained in:
yuyi 2022-06-29 21:14:03 +08:00 committed by GitHub
parent 1b0754e4f3
commit f2be115f7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -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 {

View File

@ -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() {

View File

@ -0,0 +1,6 @@
type A = int | string
fn main() {
a := A(11)
println(a)
}