parser: error if parameter name starts with a capital (#13827)
parent
8c396356bb
commit
fcb57312b9
|
@ -832,7 +832,12 @@ fn (mut p Parser) fn_args() ([]ast.Param, bool, bool) {
|
|||
p.next()
|
||||
}
|
||||
mut arg_pos := [p.tok.pos()]
|
||||
mut arg_names := [p.check_name()]
|
||||
name := p.check_name()
|
||||
mut arg_names := [name]
|
||||
if name.len > 0 && name[0].is_capital() {
|
||||
p.error_with_pos('parameter name must not begin with upper case letter (`${arg_names[0]}`)',
|
||||
p.prev_tok.pos())
|
||||
}
|
||||
mut type_pos := [p.tok.pos()]
|
||||
// `a, b, c int`
|
||||
for p.tok.kind == .comma {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
vlib/v/parser/tests/fn_param_name_cap.vv:6:9: error: parameter name must not begin with upper case letter (`T`)
|
||||
4 | fn f(Type)
|
||||
5 |
|
||||
6 | fn g<T>(T v) {
|
||||
| ^
|
||||
7 |
|
||||
8 | }
|
|
@ -0,0 +1,10 @@
|
|||
type Type = int
|
||||
|
||||
// OK
|
||||
fn f(Type)
|
||||
|
||||
fn g<T>(T v) {
|
||||
|
||||
}
|
||||
|
||||
g(5)
|
Loading…
Reference in New Issue