checker: set fn arg expected_type
							parent
							
								
									becd87141c
								
							
						
					
					
						commit
						d7a8b1b4f2
					
				|  | @ -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{ | ||||
|  |  | |||
|  | @ -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) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue