Skip to content

Commit 55193cb

Browse files
committedJun 20, 2018
fix runtime fn ptr equality codegen
closes #1140
·
0.15.20.3.0
1 parent 7c99c30 commit 55193cb

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed
 

‎src/codegen.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,12 +2246,12 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutable *executable,
22462246
} else if (type_entry->id == TypeTableEntryIdInt) {
22472247
LLVMIntPredicate pred = cmp_op_to_int_predicate(op_id, type_entry->data.integral.is_signed);
22482248
return LLVMBuildICmp(g->builder, pred, op1_value, op2_value, "");
2249-
} else if (type_entry->id == TypeTableEntryIdEnum) {
2250-
LLVMIntPredicate pred = cmp_op_to_int_predicate(op_id, false);
2251-
return LLVMBuildICmp(g->builder, pred, op1_value, op2_value, "");
2252-
} else if (type_entry->id == TypeTableEntryIdErrorSet ||
2249+
} else if (type_entry->id == TypeTableEntryIdEnum ||
2250+
type_entry->id == TypeTableEntryIdErrorSet ||
22532251
type_entry->id == TypeTableEntryIdPointer ||
2254-
type_entry->id == TypeTableEntryIdBool)
2252+
type_entry->id == TypeTableEntryIdBool ||
2253+
type_entry->id == TypeTableEntryIdPromise ||
2254+
type_entry->id == TypeTableEntryIdFn)
22552255
{
22562256
LLVMIntPredicate pred = cmp_op_to_int_predicate(op_id, false);
22572257
return LLVMBuildICmp(g->builder, pred, op1_value, op2_value, "");

‎test/cases/misc.zig‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,3 +701,8 @@ test "comptime cast fn to ptr" {
701701
const addr2 = @ptrCast(*const u8, emptyFn);
702702
comptime assert(addr1 == addr2);
703703
}
704+
705+
test "equality compare fn ptrs" {
706+
var a = emptyFn;
707+
assert(a == a);
708+
}

0 commit comments

Comments
 (0)
Please sign in to comment.