File tree Expand file tree Collapse file tree 4 files changed +7
-3
lines changed Expand file tree Collapse file tree 4 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,9 @@ fn C.tolower(c int) int
171
171
[trusted]
172
172
fn C.toupper (c int ) int
173
173
174
+ [trusted]
175
+ fn C.strchr (s & char, c int ) & char
176
+
174
177
[trusted]
175
178
fn C.getchar () int
176
179
Original file line number Diff line number Diff line change @@ -2704,7 +2704,8 @@ pub fn (mut c Checker) cast_expr(mut node ast.CastExpr) ast.Type {
2704
2704
}
2705
2705
}
2706
2706
}
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 {
2708
2709
c.error ('cannot cast to bool - use e.g. `some_int != 0` instead' , node.pos)
2709
2710
} else if from_type == ast.none_type && ! to_type.has_flag (.optional) {
2710
2711
type_name := c.table.type_to_str (to_type)
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ pub fn (mut c Checker) if_expr(mut node ast.IfExpr) ast.Type {
28
28
mut is_comptime_type_is_expr := false // if `$if T is string`
29
29
for i in 0 .. node.branches.len {
30
30
mut branch := node.branches[i]
31
- if branch.cond is ast.ParExpr {
31
+ if branch.cond is ast.ParExpr && ! c.pref.translated {
32
32
c.error ('unnecessary `()` in `$if_kind ` condition, use `$if_kind expr {` instead of `$if_kind (expr) {`.' ,
33
33
branch.pos)
34
34
}
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import strings
8
8
pub fn (mut c Checker) match_expr (mut node ast.MatchExpr) ast.Type {
9
9
node.is_expr = c.expected_type != ast.void_type
10
10
node.expected_type = c.expected_type
11
- if node.cond is ast.ParExpr {
11
+ if node.cond is ast.ParExpr && ! c.pref.translated {
12
12
c.error ('unnecessary `()` in `match` condition, use `match expr {` instead of `match (expr) {`.' ,
13
13
node.cond.pos)
14
14
}
You can’t perform that action at this time.
0 commit comments