ability to compare booleans

This commit is contained in:
Andrew Kelley 2016-04-26 11:39:31 -07:00
parent d1fa5692c6
commit 8ec109de3c
2 changed files with 10 additions and 1 deletions

View File

@ -1543,7 +1543,8 @@ static LLVMValueRef gen_cmp_expr(CodeGen *g, AstNode *node) {
zig_unreachable();
}
} else if (op1_type->id == TypeTableEntryIdPureError ||
op1_type->id == TypeTableEntryIdPointer)
op1_type->id == TypeTableEntryIdPointer ||
op1_type->id == TypeTableEntryIdBool)
{
LLVMIntPredicate pred = cmp_op_to_int_predicate(node->data.bin_op_expr.bin_op, false);
return LLVMBuildICmp(g->builder, pred, val1, val2, "");

View File

@ -1368,3 +1368,11 @@ error NoMem;
error CrappedOut;
#static_eval_enable(false)
fn returns_ten() -> %i32 { 10 }
#attribute("test")
fn bool_cmp() {
assert(test_bool_cmp(true, false) == false);
}
#static_eval_enable(false)
fn test_bool_cmp(a: bool, b: bool) -> bool { a == b }