diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index ad02b1566a..55ddee1bbd 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -7,7 +7,6 @@ import os import time import v.cflag import v.pref -import v.util import term const ( diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index caf7dd7e78..7a32e1aca5 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -935,6 +935,9 @@ pub fn (mut c Checker) check_expr_opt_call(x ast.Expr, xtype table.Type, is_retu ast.CallExpr { if it.return_type.flag_is(.optional) { c.check_or_block(it, xtype, is_return_used) + } else if it.or_block.is_used { + c.error('unexpected `or` block, the function does not return an optional', + it.pos) } } else {} diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index d495973ffb..4969f03ffd 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -61,9 +61,8 @@ pub fn (mut p Parser) call_expr(is_c, is_js bool, mod string) ast.CallExpr { // `foo()?` p.next() is_or_block_used = true - //mut s := ast.Stmt{} - //s = ast.ReturnStmt{} - + // mut s := ast.Stmt{} + // s = ast.ReturnStmt{} or_stmts << ast.Return{} } node := ast.CallExpr{