aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-03-19 13:18:14 -0400
committerAndrew Kelley <andrew@ziglang.org>2020-03-19 13:18:14 -0400
commit1d7861a36e1bcd8f7bfdb53716ef53467704922b (patch)
treea63abc081b671ea77d082d62053af37dcef14aac /src/codegen.cpp
parent8ddf9d84ffb208042ae7ea0fb3dc9fbfb2b5c983 (diff)
downloadzig-1d7861a36e1bcd8f7bfdb53716ef53467704922b.tar.gz
zig-1d7861a36e1bcd8f7bfdb53716ef53467704922b.zip
fix incorrect sentinel check
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 21e74ba609..8fae16e551 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -5425,17 +5425,9 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI
return nullptr;
}
- ZigValue *sentinel = nullptr;
- if (result_type->id == ZigTypeIdPointer) {
- ZigType *result_array_type = result_type->data.pointer.child_type;
- ir_assert(result_array_type->id == ZigTypeIdArray, &instruction->base);
- sentinel = result_array_type->data.array.sentinel;
- } else if (result_type->id == ZigTypeIdStruct) {
- ZigType *res_slice_ptr_type = result_type->data.structure.fields[slice_ptr_index]->type_entry;
- sentinel = res_slice_ptr_type->data.pointer.sentinel;
- } else {
- zig_unreachable();
- }
+ // This is not whether the result type has a sentinel, but whether there should be a sentinel check,
+ // e.g. if they used [a..b :s] syntax.
+ ZigValue *sentinel = instruction->sentinel;
if (array_type->id == ZigTypeIdArray ||
(array_type->id == ZigTypeIdPointer && array_type->data.pointer.ptr_len == PtrLenSingle))