diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 765ac9d34a..80b9bd92ea 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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 } diff --git a/vlib/v/checker/tests/fn_selector_expr_err.out b/vlib/v/checker/tests/fn_selector_expr_err.out new file mode 100644 index 0000000000..71a66a1cf5 --- /dev/null +++ b/vlib/v/checker/tests/fn_selector_expr_err.out @@ -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 + | ~~~~~~~~ diff --git a/vlib/v/checker/tests/fn_selector_expr_err.vv b/vlib/v/checker/tests/fn_selector_expr_err.vv new file mode 100644 index 0000000000..c7c7adb195 --- /dev/null +++ b/vlib/v/checker/tests/fn_selector_expr_err.vv @@ -0,0 +1 @@ +println('Hello, World!').whatever