1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

js: fix int division (#5701)

This commit is contained in:
Leah Lundqvist 2020-07-06 15:24:24 +02:00 committed by GitHub
parent 6b2777e681
commit 659aa8db3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1339,6 +1339,11 @@ fn (mut g JsGen) gen_infix_expr(it ast.InfixExpr) {
}
g.expr(it.right)
// Int division: 2.5 -> 2 by prepending |0
if it.op == .div && it.left_type == table.any_int_type_idx && it.right_type == table.any_int_type_idx {
g.write('|0')
}
}
}