diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-02-01 02:11:46 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-02-01 02:11:46 -0700 |
| commit | 179443bd61c85c7d808304dc334bb407aa793988 (patch) | |
| tree | 5c743af7c986521be3ceaf366738daf22ece139e /src/analyze.cpp | |
| parent | b3459f64e795118c4c12890ed0fec75638b74a2c (diff) | |
| download | zig-179443bd61c85c7d808304dc334bb407aa793988.tar.gz zig-179443bd61c85c7d808304dc334bb407aa793988.zip | |
add ?? prefix operator
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index e71c762669..6e3abdac35 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -4207,6 +4207,20 @@ static TypeTableEntry *analyze_prefix_op_expr(CodeGen *g, ImportTableEntry *impo return g->builtin_types.entry_invalid; } } + case PrefixOpUnwrapMaybe: + { + TypeTableEntry *type_entry = analyze_expression(g, import, context, nullptr, expr_node); + + if (type_entry->id == TypeTableEntryIdInvalid) { + return type_entry; + } else if (type_entry->id == TypeTableEntryIdMaybe) { + return type_entry->data.maybe.child_type; + } else { + add_node_error(g, expr_node, + buf_sprintf("expected maybe type, got '%s'", buf_ptr(&type_entry->name))); + return g->builtin_types.entry_invalid; + } + } } zig_unreachable(); } |
