mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-07-13 21:41:58 +00:00
Cast to bool by comparing to zero (#343)
This commit is contained in:
@ -7516,9 +7516,10 @@ export class Compiler extends DiagnosticEmitter {
|
||||
}
|
||||
case TypeKind.BOOL: {
|
||||
if (flow.canOverflow(expr, type)) {
|
||||
expr = module.createBinary(BinaryOp.AndI32,
|
||||
// bool is special in that it compares to 0 instead of masking with 0x1
|
||||
expr = module.createBinary(BinaryOp.NeI32,
|
||||
expr,
|
||||
module.createI32(0x1)
|
||||
module.createI32(0)
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user