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

master
Delyan Angelov 2022-06-03 20:53:10 +03:00
parent 6f9070e06d
commit c15d1c6e7e
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
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)])