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

v2: minor fixes

This commit is contained in:
Alexander Medvednikov 2020-02-10 13:58:24 +01:00
parent 211d35d647
commit 3f6ccd3120
2 changed files with 15 additions and 20 deletions

View File

@ -142,7 +142,7 @@ pub fn new_v(args []string) &compiler.V {
build_mode: build_mode build_mode: build_mode
cflags: cflags cflags: cflags
ccompiler: ccompiler ccompiler: ccompiler
building_v: !is_repl && (rdir_name == 'compiler' || rdir_name == 'v.v' || rdir_name == 'vfmt.v' || rdir_name == 'cmd/v' || dir.contains('vlib')) building_v: !is_repl && (rdir_name == 'compiler' || rdir_name == 'v' || rdir_name == 'vfmt.v' || rdir_name == 'cmd/v' || dir.contains('vlib'))
// is_fmt: comptime_define == 'vfmt' // is_fmt: comptime_define == 'vfmt'
user_mod_path: user_mod_path user_mod_path: user_mod_path

View File

@ -171,29 +171,24 @@ pub fn (c &Checker) call_expr(call_expr ast.CallExpr) table.Type {
fn_name := call_expr.name fn_name := call_expr.name
if f := c.table.find_fn(fn_name) { if f := c.table.find_fn(fn_name) {
// return_ti := f.return_ti // return_ti := f.return_ti
if /*TODO:*/!f.is_c { if f.is_c {
return f.return_type
}
if call_expr.args.len < f.args.len { if call_expr.args.len < f.args.len {
c.error('too few arguments in call to `$fn_name`', call_expr.pos) c.error('too few arguments in call to `$fn_name`', call_expr.pos)
} }
else if !f.is_variadic && call_expr.args.len > f.args.len { else if !f.is_variadic && call_expr.args.len > f.args.len {
c.error('too many arguments in call to `$fn_name` ($call_expr.args.len instead of $f.args.len)', call_expr.pos) c.error('too many arguments in call to `$fn_name` ($call_expr.args.len instead of $f.args.len)', call_expr.pos)
} }
}
if /*TODO:*/!f.is_c {
for i, arg_expr in call_expr.args { for i, arg_expr in call_expr.args {
arg := if f.is_variadic && i >= f.args.len-1 { arg := if f.is_variadic && i >= f.args.len - 1 { f.args[f.args.len - 1] } else { f.args[i] }
f.args[f.args.len-1]
} else {
f.args[i]
}
typ := c.expr(arg_expr) typ := c.expr(arg_expr)
typ_sym := c.table.get_type_symbol(typ) typ_sym := c.table.get_type_symbol(typ)
arg_typ_sym := c.table.get_type_symbol(arg.typ) arg_typ_sym := c.table.get_type_symbol(arg.typ)
if /*TODO:*/!f.is_c && !c.table.check(typ, arg.typ) { if !c.table.check(typ, arg.typ) {
c.error('!cannot use type `$typ_sym.name` as type `$arg_typ_sym.name` in argument ${i+1} to `$fn_name`', call_expr.pos) c.error('!cannot use type `$typ_sym.name` as type `$arg_typ_sym.name` in argument ${i+1} to `$fn_name`', call_expr.pos)
} }
} }
}
return f.return_type return f.return_type
} }
c.error('unknown fn: $fn_name', call_expr.pos) c.error('unknown fn: $fn_name', call_expr.pos)