Skip to content

Commit ace9444

Browse files
committed
checker: more c2v fixes
1 parent 1999fb9 commit ace9444

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

vlib/v/checker/checker.v

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2852,6 +2852,19 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool)
28522852
if typ == ast.int_type && param_typ_sym.kind == .enum_ {
28532853
continue
28542854
}
2855+
// In C unsafe number casts are used all the time (e.g. `char*` where
2856+
// `int*` is expected etc), so just allow them all.
2857+
mut param_is_number := param.typ.is_number()
2858+
if param.typ.is_ptr() {
2859+
param_is_number = param.typ.deref().is_number()
2860+
}
2861+
mut typ_is_number := typ.is_number()
2862+
if typ.is_ptr() {
2863+
typ_is_number = typ.deref().is_number()
2864+
}
2865+
if param_is_number && typ_is_number {
2866+
continue
2867+
}
28552868
}
28562869
c.error('$err.msg in argument ${i + 1} to `$fn_name`', call_arg.pos)
28572870
}
@@ -6374,7 +6387,7 @@ fn (mut c Checker) match_exprs(mut node ast.MatchExpr, cond_type_sym ast.TypeSym
63746387
}
63756388
}
63766389
if is_exhaustive {
6377-
if has_else {
6390+
if has_else && !c.pref.translated {
63786391
c.error('match expression is exhaustive, `else` is unnecessary', else_branch.pos)
63796392
}
63806393
return

0 commit comments

Comments
 (0)