fix %% prefix operator codegen for simple values

closes #93
This commit is contained in:
Andrew Kelley
2016-01-27 14:49:48 -07:00
parent 0a26586724
commit b508441859
2 changed files with 17 additions and 1 deletions

View File

@@ -916,11 +916,12 @@ static LLVMValueRef gen_prefix_op_expr(CodeGen *g, AstNode *node) {
TypeTableEntry *child_type = expr_type->data.error.child_type;
// TODO in debug mode, put a panic here if the error is not 0
if (child_type->size_in_bits > 0) {
add_debug_source_node(g, node);
LLVMValueRef child_val_ptr = LLVMBuildStructGEP(g->builder, expr_val, 1, "");
if (handle_is_ptr(child_type)) {
return child_val_ptr;
} else {
return expr_val;
return LLVMBuildLoad(g->builder, child_val_ptr, "");
}
} else {
return nullptr;