Skip to content

Commit 38d3239

Browse files
committed
checker: c2v fixes
1 parent c48a9e7 commit 38d3239

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

vlib/builtin/cfns.c.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ fn C.tolower(c int) int
171171
[trusted]
172172
fn C.toupper(c int) int
173173

174+
[trusted]
175+
fn C.strchr(s &char, c int) &char
176+
174177
[trusted]
175178
fn C.getchar() int
176179

vlib/v/checker/checker.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2704,7 +2704,8 @@ pub fn (mut c Checker) cast_expr(mut node ast.CastExpr) ast.Type {
27042704
}
27052705
}
27062706
}
2707-
} else if to_type == ast.bool_type && from_type != ast.bool_type && !c.inside_unsafe {
2707+
} else if to_type == ast.bool_type && from_type != ast.bool_type && !c.inside_unsafe
2708+
&& !c.pref.translated {
27082709
c.error('cannot cast to bool - use e.g. `some_int != 0` instead', node.pos)
27092710
} else if from_type == ast.none_type && !to_type.has_flag(.optional) {
27102711
type_name := c.table.type_to_str(to_type)

vlib/v/checker/if.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn (mut c Checker) if_expr(mut node ast.IfExpr) ast.Type {
2828
mut is_comptime_type_is_expr := false // if `$if T is string`
2929
for i in 0 .. node.branches.len {
3030
mut branch := node.branches[i]
31-
if branch.cond is ast.ParExpr {
31+
if branch.cond is ast.ParExpr && !c.pref.translated {
3232
c.error('unnecessary `()` in `$if_kind` condition, use `$if_kind expr {` instead of `$if_kind (expr) {`.',
3333
branch.pos)
3434
}

vlib/v/checker/match.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import strings
88
pub fn (mut c Checker) match_expr(mut node ast.MatchExpr) ast.Type {
99
node.is_expr = c.expected_type != ast.void_type
1010
node.expected_type = c.expected_type
11-
if node.cond is ast.ParExpr {
11+
if node.cond is ast.ParExpr && !c.pref.translated {
1212
c.error('unnecessary `()` in `match` condition, use `match expr {` instead of `match (expr) {`.',
1313
node.cond.pos)
1414
}

0 commit comments

Comments
 (0)