aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-25 15:45:05 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-25 15:45:05 -0700
commitdeb35868841fc3eb99228fe102a5b8ed1991d51f (patch)
treee84077cf298eec6f95cd3a75f1f05cd4cb0b501f /src/analyze.cpp
parentc0dc0ca6c90649f157dfcb43c7ec69fa4b5f6b09 (diff)
downloadzig-deb35868841fc3eb99228fe102a5b8ed1991d51f.tar.gz
zig-deb35868841fc3eb99228fe102a5b8ed1991d51f.zip
implement %% prefix operator
See #23 also make undefined constants use llvm undef value
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index b43d7dfe30..9556b32089 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -3656,6 +3656,20 @@ static TypeTableEntry *analyze_prefix_op_expr(CodeGen *g, ImportTableEntry *impo
}
}
+ case PrefixOpUnwrapError:
+ {
+ TypeTableEntry *type_entry = analyze_expression(g, import, context, nullptr, expr_node);
+
+ if (type_entry->id == TypeTableEntryIdInvalid) {
+ return type_entry;
+ } else if (type_entry->id == TypeTableEntryIdErrorUnion) {
+ return type_entry->data.error.child_type;
+ } else {
+ add_node_error(g, expr_node,
+ buf_sprintf("expected error type, got '%s'", buf_ptr(&type_entry->name)));
+ return g->builtin_types.entry_invalid;
+ }
+ }
}
zig_unreachable();
}