aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 08d191a505..e81437c66a 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -284,6 +284,13 @@ static LLVMValueRef gen_cast_expr(CodeGen *g, AstNode *node) {
zig_unreachable();
case CastOpNoop:
return expr_val;
+ case CastOpErrToInt:
+ assert(actual_type->id == TypeTableEntryIdError);
+ if (actual_type->data.error.child_type->size_in_bits == 0) {
+ return expr_val;
+ } else {
+ zig_panic("TODO");
+ }
case CastOpMaybeWrap:
{
assert(cast_expr->tmp_ptr);
@@ -2122,6 +2129,12 @@ static LLVMValueRef gen_const_val(CodeGen *g, TypeTableEntry *type_entry, ConstE
} else {
return global_value;
}
+ } else if (type_entry->id == TypeTableEntryIdError) {
+ if (type_entry->data.error.child_type->size_in_bits == 0) {
+ return LLVMConstInt(g->err_tag_type->type_ref, const_val->data.x_err->value, false);
+ } else {
+ zig_panic("TODO");
+ }
} else {
zig_unreachable();
}