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

checker: add error for println('x').abcd (#15423)

This commit is contained in:
Swastik Baranwal 2022-08-14 12:13:54 +05:30 committed by GitHub
parent 4c0339242a
commit 7280d4c95a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 1 deletions

View File

@ -1129,7 +1129,7 @@ pub fn (mut c Checker) selector_expr(mut node ast.SelectorExpr) ast.Type {
if typ == ast.void_type_idx {
// This means that the field has an undefined type.
// This error was handled before.
// c.error('`void` type has no fields', node.pos)
c.error('`$node.expr` does not return a value', node.pos)
node.expr_type = ast.void_type
return ast.void_type
}

View File

@ -0,0 +1,3 @@
vlib/v/checker/tests/fn_selector_expr_err.vv:1:26: error: `println('Hello, World!')` does not return a value
1 | println('Hello, World!').whatever
| ~~~~~~~~

View File

@ -0,0 +1 @@
println('Hello, World!').whatever