diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-04-06 14:08:23 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-04-06 14:09:27 -0700 |
| commit | 7bb67b1fd0ca56a04778083f1a01583d839be9b1 (patch) | |
| tree | 2eadc6f2c7ce6cb3d2adca58c6dbcd16ef05ee2a /src/analyze.cpp | |
| parent | 22ef416d4de6e37fbe8428351c4043e5acc3c818 (diff) | |
| download | zig-7bb67b1fd0ca56a04778083f1a01583d839be9b1.tar.gz zig-7bb67b1fd0ca56a04778083f1a01583d839be9b1.zip | |
ability to compare function pointers at compile time
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 99f1dac3c4..91fbddf717 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -2909,6 +2909,16 @@ static TypeTableEntry *analyze_bool_bin_op_expr(CodeGen *g, ImportTableEntry *im } else { zig_unreachable(); } + } else if (resolved_type->id == TypeTableEntryIdFn) { + bool are_equal = (op1_val->data.x_fn == op2_val->data.x_fn); + + if (bin_op_type == BinOpTypeCmpEq) { + answer = are_equal; + } else if (bin_op_type == BinOpTypeCmpNotEq) { + answer = !are_equal; + } else { + zig_unreachable(); + } } else { zig_unreachable(); } |
