parser: require anonymous fn to use `_` for unused parameters (#9262)
Fixes a C error with gcc.pull/9266/head^2
parent
504b87bcfd
commit
3be78d6777
|
@ -544,6 +544,9 @@ fn (mut p Parser) anon_fn() ast.AnonFn {
|
|||
// TODO generics
|
||||
args, _, is_variadic := p.fn_args()
|
||||
for arg in args {
|
||||
if arg.name.len == 0 {
|
||||
p.error_with_pos('use `_` to name an unused parameter', arg.pos)
|
||||
}
|
||||
p.scope.register(ast.Var{
|
||||
name: arg.name
|
||||
typ: arg.typ
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
vlib/v/parser/tests/anon_unused_param.vv:1:9: error: use `_` to name an unused parameter
|
||||
1 | _ = fn (int){}
|
||||
| ~~~
|
||||
2 |
|
|
@ -0,0 +1,2 @@
|
|||
_ = fn (int){}
|
||||
|
Loading…
Reference in New Issue