checker: handle unexpected `or` blocks
parent
e5d4786371
commit
f49ef39708
|
@ -7,7 +7,6 @@ import os
|
|||
import time
|
||||
import v.cflag
|
||||
import v.pref
|
||||
import v.util
|
||||
import term
|
||||
|
||||
const (
|
||||
|
|
|
@ -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 {}
|
||||
|
|
|
@ -63,7 +63,6 @@ pub fn (mut p Parser) call_expr(is_c, is_js bool, mod string) ast.CallExpr {
|
|||
is_or_block_used = true
|
||||
// mut s := ast.Stmt{}
|
||||
// s = ast.ReturnStmt{}
|
||||
|
||||
or_stmts << ast.Return{}
|
||||
}
|
||||
node := ast.CallExpr{
|
||||
|
|
Loading…
Reference in New Issue