mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: change optional to result in vlib/v. (#16177)
This commit is contained in:
@@ -599,7 +599,7 @@ fn (c &Checker) promote_num(left_type ast.Type, right_type ast.Type) ast.Type {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (mut c Checker) check_expected(got ast.Type, expected ast.Type) ? {
|
||||
pub fn (mut c Checker) check_expected(got ast.Type, expected ast.Type) ! {
|
||||
if !c.check_types(got, expected) {
|
||||
return error(c.expected_msg(got, expected))
|
||||
}
|
||||
|
||||
@@ -3199,16 +3199,16 @@ pub fn (mut c Checker) unsafe_expr(mut node ast.UnsafeExpr) ast.Type {
|
||||
return t
|
||||
}
|
||||
|
||||
fn (mut c Checker) find_definition(ident ast.Ident) ?ast.Expr {
|
||||
fn (mut c Checker) find_definition(ident ast.Ident) !ast.Expr {
|
||||
match ident.kind {
|
||||
.unresolved, .blank_ident { return none }
|
||||
.unresolved, .blank_ident { return error('none') }
|
||||
.variable, .constant { return c.find_obj_definition(ident.obj) }
|
||||
.global { return error('$ident.name is a global variable') }
|
||||
.function { return error('$ident.name is a function') }
|
||||
}
|
||||
}
|
||||
|
||||
fn (mut c Checker) find_obj_definition(obj ast.ScopeObject) ?ast.Expr {
|
||||
fn (mut c Checker) find_obj_definition(obj ast.ScopeObject) !ast.Expr {
|
||||
// TODO: remove once we have better type inference
|
||||
mut name := ''
|
||||
match obj {
|
||||
|
||||
@@ -1914,7 +1914,7 @@ fn (mut c Checker) post_process_generic_fns() {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (mut c Checker) check_expected_arg_count(mut node ast.CallExpr, f &ast.Fn) ? {
|
||||
pub fn (mut c Checker) check_expected_arg_count(mut node ast.CallExpr, f &ast.Fn) ! {
|
||||
nr_args := node.args.len
|
||||
nr_params := if node.is_method && f.params.len > 0 { f.params.len - 1 } else { f.params.len }
|
||||
mut min_required_params := f.params.len
|
||||
|
||||
Reference in New Issue
Block a user