| author | |
| committer | |
| log | b50844185991a86bac462346413341b87eda14cd |
| tree | 9e6c23c5db7785ae6abba756758345768d523a4f |
| parent | 0a265867242757accd9a8dafee2f6cce7c738f29 |
closes #932 files changed, 17 insertions(+), 1 deletions(-)
src/codegen.cpp+2-1| ... | @@ -916,11 +916,12 @@ static LLVMValueRef gen_prefix_op_expr(CodeGen *g, AstNode *node) { | ... | @@ -916,11 +916,12 @@ static LLVMValueRef gen_prefix_op_expr(CodeGen *g, AstNode *node) { |
| 916 | TypeTableEntry *child_type = expr_type->data.error.child_type; | 916 | TypeTableEntry *child_type = expr_type->data.error.child_type; |
| 917 | // TODO in debug mode, put a panic here if the error is not 0 | 917 | // TODO in debug mode, put a panic here if the error is not 0 |
| 918 | if (child_type->size_in_bits > 0) { | 918 | if (child_type->size_in_bits > 0) { |
| 919 | add_debug_source_node(g, node); | ||
| 919 | LLVMValueRef child_val_ptr = LLVMBuildStructGEP(g->builder, expr_val, 1, ""); | 920 | LLVMValueRef child_val_ptr = LLVMBuildStructGEP(g->builder, expr_val, 1, ""); |
| 920 | if (handle_is_ptr(child_type)) { | 921 | if (handle_is_ptr(child_type)) { |
| 921 | return child_val_ptr; | 922 | return child_val_ptr; |
| 922 | } else { | 923 | } else { |
| 923 | return expr_val; | 924 | return LLVMBuildLoad(g->builder, child_val_ptr, ""); |
| 924 | } | 925 | } |
| 925 | } else { | 926 | } else { |
| 926 | return nullptr; | 927 | return nullptr; |
test/run_tests.cpp+15| ... | @@ -1329,6 +1329,21 @@ fn f() -> &void { | ... | @@ -1329,6 +1329,21 @@ fn f() -> &void { |
| 1329 | pub fn main(args: [][]u8) -> %void { | 1329 | pub fn main(args: [][]u8) -> %void { |
| 1330 | const a = f(); | 1330 | const a = f(); |
| 1331 | return *a; | 1331 | return *a; |
| 1332 | } | ||
| 1333 | )SOURCE", "OK\n"); | ||
| 1334 | |||
| 1335 | add_simple_case("unwrap simple value from error", R"SOURCE( | ||
| 1336 | import "std.zig"; | ||
| 1337 | fn do() -> %isize { | ||
| 1338 | 13 | ||
| 1339 | } | ||
| 1340 | |||
| 1341 | pub fn main(args: [][]u8) -> %void { | ||
| 1342 | const i = %%do(); | ||
| 1343 | if (i != 13) { | ||
| 1344 | %%stdout.printf("BAD\n"); | ||
| 1345 | } | ||
| 1346 | %%stdout.printf("OK\n"); | ||
| 1332 | } | 1347 | } |
| 1333 | )SOURCE", "OK\n"); | 1348 | )SOURCE", "OK\n"); |
| 1334 | } | 1349 | } |