mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v2: checker: fix filter()
This commit is contained in:
parent
b580a497fe
commit
b1357d9641
@ -20,6 +20,7 @@ fn launch_tool(is_verbose bool, tname string, cmdname string) {
|
|||||||
tname_index = os.args.len
|
tname_index = os.args.len
|
||||||
}
|
}
|
||||||
mut compilation_options := os.args[1..tname_index].clone()
|
mut compilation_options := os.args[1..tname_index].clone()
|
||||||
|
//f := os.args.join(' ')
|
||||||
tool_args := os.args[1..].join(' ')
|
tool_args := os.args[1..].join(' ')
|
||||||
tool_exe := path_of_executable(os.realpath('$vroot/cmd/tools/$tname'))
|
tool_exe := path_of_executable(os.realpath('$vroot/cmd/tools/$tname'))
|
||||||
tool_source := os.realpath('$vroot/cmd/tools/${tname}.v')
|
tool_source := os.realpath('$vroot/cmd/tools/${tname}.v')
|
||||||
|
@ -222,6 +222,10 @@ pub fn (c mut Checker) check_method_call_expr(method_call_expr ast.MethodCallExp
|
|||||||
return method.return_type
|
return method.return_type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if typ_sym.kind == .array && method_call_expr.name == 'filter' {
|
||||||
|
// info := typ_sym.info as table.Array
|
||||||
|
return typ // info.elem_type
|
||||||
|
}
|
||||||
c.error('type `$typ_sym.name` has no method `$method_call_expr.name`', method_call_expr.pos)
|
c.error('type `$typ_sym.name` has no method `$method_call_expr.name`', method_call_expr.pos)
|
||||||
return table.void_type
|
return table.void_type
|
||||||
}
|
}
|
||||||
@ -284,25 +288,25 @@ pub fn (c mut Checker) return_stmt(return_stmt ast.Return) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn (c mut Checker) assign_stmt(assign_stmt ast.AssignStmt) {
|
pub fn (c mut Checker) assign_stmt(assign_stmt ast.AssignStmt) {
|
||||||
// multi return
|
// multi return
|
||||||
if assign_stmt.left.len > assign_stmt.right.len {
|
if assign_stmt.left.len > assign_stmt.right.len {
|
||||||
right := c.expr(assign_stmt.right[0])
|
right := c.expr(assign_stmt.right[0])
|
||||||
right_sym := c.table.get_type_symbol(right)
|
right_sym := c.table.get_type_symbol(right)
|
||||||
info := right_sym.mr_info()
|
info := right_sym.mr_info()
|
||||||
if right_sym.kind != .multi_return {
|
if right_sym.kind != .multi_return {
|
||||||
c.error('wrong number of vars', assign_stmt.pos)
|
c.error('wrong number of vars', assign_stmt.pos)
|
||||||
}
|
}
|
||||||
mut scope := c.file.scope.innermost(assign_stmt.pos.pos) or {
|
mut scope := c.file.scope.innermost(assign_stmt.pos.pos) or {
|
||||||
c.file.scope
|
c.file.scope
|
||||||
}
|
}
|
||||||
for i, ident in assign_stmt.left {
|
for i, ident in assign_stmt.left {
|
||||||
// TODO: check types
|
// TODO: check types
|
||||||
scope.override_var(ast.VarDecl{
|
scope.override_var(ast.VarDecl{
|
||||||
name: ident.name
|
name: ident.name
|
||||||
typ: info.types[i]
|
typ: info.types[i]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: multiple assign
|
// TODO: multiple assign
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user