diff --git a/vlib/compiler/gen_c.v b/vlib/compiler/gen_c.v index bb2b83b7c1..40496c61f2 100644 --- a/vlib/compiler/gen_c.v +++ b/vlib/compiler/gen_c.v @@ -628,15 +628,15 @@ fn (p mut Parser) cast(typ string) { p.error('cannot cast `bool` to `$typ`') } if typ != expr_typ && typ in p.table.sum_types { - T := p.table.find_type(typ) - if expr_typ in T.ctype_names { + tt := p.table.find_type(typ) + if expr_typ in tt.ctype_names { // There is no need for a cast here, since it was already done // in p.bool_expression, SUM TYPE CAST2 . Besides, doubling the // cast here causes MSVC to complain with: // error C2440: 'type cast': cannot convert from 'ExprType' to 'ExprType' p.cgen.set_placeholder(pos, '(') }else{ - p.warn('only $T.ctype_names can be casted to `$typ`') + p.warn('only $tt.ctype_names can be casted to `$typ`') p.error('cannot cast `$expr_typ` to `$typ`') } }else{ diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 608c0ed414..d53debf25a 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -206,6 +206,7 @@ pub fn (c mut Checker) call_expr(call_expr ast.CallExpr) table.Type { } 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] } + c.expected_type = arg.typ typ := c.expr(arg_expr) typ_sym := c.table.get_type_symbol(typ) arg_typ_sym := c.table.get_type_symbol(arg.typ)