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

checker: give a checker error message on print(1), print(2) (fix #16311) (#16314)

This commit is contained in:
shove 2022-11-03 23:28:59 +08:00 committed by GitHub
parent 962d0babdc
commit 0e8d148fe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -3112,6 +3112,12 @@ pub fn (mut c Checker) concat_expr(mut node ast.ConcatExpr) ast.Type {
node.return_type = typ
return typ
} else {
for i := 0; i < mr_types.len; i++ {
if mr_types[i] == ast.void_type {
c.error('type `void` cannot be used in multi-return', node.vals[i].pos())
return ast.void_type
}
}
typ := c.table.find_or_register_multi_return(mr_types)
ast.new_type(typ)
node.return_type = typ

View File

@ -0,0 +1,5 @@
vlib/v/checker/tests/multi_return_use_void_type_err.vv:2:2: error: type `void` cannot be used in multi-return
1 | fn main() {
2 | print('a'), print('b')
| ~~~~~~~~~~
3 | }

View File

@ -0,0 +1,3 @@
fn main() {
print('a'), print('b')
}