@@ -2456,7 +2456,7 @@ pub fn (mut c Checker) fn_call(mut call_expr ast.CallExpr) ast.Type {
2456
2456
typ := c.check_expr_opt_call (call_arg.expr, c.expr (call_arg.expr))
2457
2457
call_expr.args[i].typ = typ
2458
2458
typ_sym := c.table.get_type_symbol (typ)
2459
- arg_typ_sym := c.table.get_type_symbol (param.typ)
2459
+ param_typ_sym := c.table.get_type_symbol (param.typ)
2460
2460
if func.is_variadic && typ.has_flag (.variadic) && call_expr.args.len - 1 > i {
2461
2461
c.error ('when forwarding a variadic variable, it must be the final argument' ,
2462
2462
call_arg.pos)
@@ -2490,12 +2490,12 @@ pub fn (mut c Checker) fn_call(mut call_expr ast.CallExpr) ast.Type {
2490
2490
c.fail_if_unreadable (call_arg.expr, typ, 'argument' )
2491
2491
}
2492
2492
}
2493
- mut final_arg_sym := arg_typ_sym
2494
- if func.is_variadic && arg_typ_sym .info is ast.Array {
2495
- final_arg_sym = c.table.get_type_symbol (arg_typ_sym .array_info ().elem_type)
2493
+ mut final_param_sym := param_typ_sym
2494
+ if func.is_variadic && param_typ_sym .info is ast.Array {
2495
+ final_param_sym = c.table.get_type_symbol (param_typ_sym .array_info ().elem_type)
2496
2496
}
2497
2497
// Handle expected interface
2498
- if final_arg_sym .kind == .interface_ {
2498
+ if final_param_sym .kind == .interface_ {
2499
2499
c.type_implements (typ, param.typ, call_arg.expr.position ())
2500
2500
continue
2501
2501
}
@@ -2506,12 +2506,21 @@ pub fn (mut c Checker) fn_call(mut call_expr ast.CallExpr) ast.Type {
2506
2506
// if arg_typ_sym.kind == .string && typ_sym.has_method('str') {
2507
2507
// continue
2508
2508
// }
2509
- if typ_sym.kind == .void && arg_typ_sym .kind == .string {
2509
+ if typ_sym.kind == .void && param_typ_sym .kind == .string {
2510
2510
continue
2511
2511
}
2512
2512
if func.generic_names.len > 0 {
2513
2513
continue
2514
2514
}
2515
+ if c.pref.translated {
2516
+ // Allow enums to be used as ints and vice versa in translated code
2517
+ if param.typ == ast.int_type && typ_sym.kind == .enum_ {
2518
+ continue
2519
+ }
2520
+ if typ == ast.int_type && param_typ_sym.kind == .enum_ {
2521
+ continue
2522
+ }
2523
+ }
2515
2524
c.error ('$err.msg in argument ${i + 1} to `$fn_name `' , call_arg.pos)
2516
2525
}
2517
2526
// Warn about automatic (de)referencing, which will be removed soon.
0 commit comments