diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index 4f154503a8..3bb22921aa 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -833,6 +833,9 @@ fn (mut p Parser) fn_args() ([]ast.Param, bool, bool) { } mut arg_pos := [p.tok.pos()] mut arg_names := [p.check_name()] + if arg_names[0][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 { diff --git a/vlib/v/parser/tests/fn_param_name_cap.out b/vlib/v/parser/tests/fn_param_name_cap.out new file mode 100644 index 0000000000..1a3f7ccf70 --- /dev/null +++ b/vlib/v/parser/tests/fn_param_name_cap.out @@ -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 v) { + | ^ + 7 | + 8 | } diff --git a/vlib/v/parser/tests/fn_param_name_cap.vv b/vlib/v/parser/tests/fn_param_name_cap.vv new file mode 100644 index 0000000000..e436179df5 --- /dev/null +++ b/vlib/v/parser/tests/fn_param_name_cap.vv @@ -0,0 +1,10 @@ +type Type = int + +// OK +fn f(Type) + +fn g(T v) { + +} + +g(5)