checker: fix unrecognised empty argument names in anon fn's (#13176)
parent
f19197f9b0
commit
9fd65b5b18
|
@ -323,6 +323,11 @@ fn (mut c Checker) anon_fn(mut node ast.AnonFn) ast.Type {
|
|||
c.table.cur_fn = keep_fn
|
||||
c.inside_anon_fn = keep_inside_anon
|
||||
}
|
||||
for param in node.decl.params {
|
||||
if param.name.len == 0 {
|
||||
c.error('use `_` to name an unused parameter', param.pos)
|
||||
}
|
||||
}
|
||||
c.table.cur_fn = unsafe { &node.decl }
|
||||
c.inside_anon_fn = true
|
||||
for mut var in node.inherited_vars {
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
vlib/v/checker/tests/anon_fn_arg_type_err.vv:6:14: error: use `_` to name an unused parameter
|
||||
4 | mut i := 1
|
||||
5 |
|
||||
6 | func := fn (i) int {
|
||||
| ^
|
||||
7 | return i
|
||||
8 | }
|
||||
vlib/v/checker/tests/anon_fn_arg_type_err.vv:7:10: error: undefined ident: `i`
|
||||
5 |
|
||||
6 | func := fn (i) int {
|
||||
|
@ -5,13 +12,6 @@ vlib/v/checker/tests/anon_fn_arg_type_err.vv:7:10: error: undefined ident: `i`
|
|||
| ^
|
||||
8 | }
|
||||
9 |
|
||||
vlib/v/checker/tests/anon_fn_arg_type_err.vv:6:14: error: unknown type `i`
|
||||
4 | mut i := 1
|
||||
5 |
|
||||
6 | func := fn (i) int {
|
||||
| ^
|
||||
7 | return i
|
||||
8 | }
|
||||
vlib/v/checker/tests/anon_fn_arg_type_err.vv:10:15: error: cannot use `int` as `i` in argument 1 to `func`
|
||||
8 | }
|
||||
9 |
|
||||
|
|
Loading…
Reference in New Issue