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
cflags: cflags
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'
user_mod_path: user_mod_path

View File

@ -111,7 +111,7 @@ fn (c &Checker) complete_types() {
// return the resolved Type from unresovled Type
pub fn (c &Checker) resolve(unresolved table.Type) table.Type {
return c.resolved[-table.type_idx(unresolved)-1]
return c.resolved[-table.type_idx(unresolved) - 1]
}
pub fn (c &Checker) check_struct_init(struct_init ast.StructInit) table.Type {
@ -171,29 +171,24 @@ pub fn (c &Checker) call_expr(call_expr ast.CallExpr) table.Type {
fn_name := call_expr.name
if f := c.table.find_fn(fn_name) {
// 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 {
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 {
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 {
arg := if f.is_variadic && i >= f.args.len-1 {
f.args[f.args.len-1]
} else {
f.args[i]
}
arg := if f.is_variadic && i >= f.args.len - 1 { f.args[f.args.len - 1] } else { f.args[i] }
typ := c.expr(arg_expr)
typ_sym := c.table.get_type_symbol(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)
}
}
}
return f.return_type
}
c.error('unknown fn: $fn_name', call_expr.pos)