From ce6f687f657057bb88711b265f0628c265e246f7 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 25 Jun 2020 14:51:58 +0200 Subject: [PATCH] checker: remove an unnecessary error for unexisting types --- vlib/v/checker/checker.v | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index fa40e56aaa..0c5008b255 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -413,8 +413,10 @@ pub fn (mut c Checker) struct_init(mut struct_init ast.StructInit) table.Type { expr_type := c.expr(field.expr) expr_type_sym := c.table.get_type_symbol(expr_type) field_type_sym := c.table.get_type_symbol(info_field.typ) - if !c.check_types(expr_type, info_field.typ) && expr_type != table.void_type { - c.error('cannot assign `$expr_type_sym.name` as `$field_type_sym.name` for field `$info_field.name`', + if !c.check_types(expr_type, info_field.typ) && expr_type != table.void_type && + expr_type_sym.kind != .placeholder { + + c.error('!cannot assign $expr_type_sym.kind `$expr_type_sym.name` as `$field_type_sym.name` for field `$info_field.name`', field.pos) } if info_field.typ.is_ptr() && !expr_type.is_ptr() && !expr_type.is_pointer() && @@ -1504,7 +1506,8 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) { else {} } // Dual sides check (compatibility check) - if !is_blank_ident && !c.check_types(right_type_unwrapped, left_type_unwrapped) { + if !is_blank_ident && !c.check_types(right_type_unwrapped, left_type_unwrapped) && + right_sym.kind != .placeholder { c.error('cannot assign `$right_sym.name` to `$left.str()` of type `$left_sym.name`', right.position()) } @@ -2708,9 +2711,8 @@ fn (mut c Checker) sql_expr(mut node ast.SqlExpr) table.Type { return node.typ } + fn (mut c Checker) sql_stmt(mut node ast.SqlStmt) table.Type { - //vlib/v/gen/sql.v:37:18: error: undefined ident: `fields` - //vlib/v/gen/sql.v:28:12: error: unknown selector expression sym := c.table.get_type_symbol(node.table_type) info := sym.info as table.Struct fields := c.fetch_and_verify_orm_fields(info, node.pos, node.table_name)