cgen,ci: fix cast_bool_to_int_test.v on windows-tcc

Delyan Angelov 2022-06-03 20:53:10 +03:00 committed by Chewing_Bever
parent 3e1ff72247
commit 54e851f8de
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
2 changed files with 6 additions and 2 deletions

View File

@ -3961,9 +3961,9 @@ fn (mut g Gen) cast_expr(node ast.CastExpr) {
g.expr(node.expr)
} else if node.expr_type == ast.bool_type && node.typ.is_int() {
styp := g.typ(node.typ)
g.write('($styp)(')
g.write('($styp[]){(')
g.expr(node.expr)
g.write(')')
g.write(')?1:0}[0]')
} else {
styp := g.typ(node.typ)
if (g.pref.translated || g.file.is_translated) && sym.kind == .function {

View File

@ -2,6 +2,10 @@ module main
fn test_cast_bool_to_int() {
i := true
x := int(i)
nx := int(!i)
dump(x)
dump(nx)
a := [1, 2, 3]
println(a[int(!i)])