Commit 1d0b729f28
Changed files (2)
src
test
cases
compile_errors
src/Sema.zig
@@ -26139,11 +26139,12 @@ fn analyzeSlice(
var array_ty = ptr_ptr_child_ty;
var slice_ty = ptr_ptr_ty;
var ptr_or_slice = ptr_ptr;
- var elem_ty = ptr_ptr_child_ty.childType();
+ var elem_ty: Type = undefined;
var ptr_sentinel: ?Value = null;
switch (ptr_ptr_child_ty.zigTypeTag()) {
.Array => {
ptr_sentinel = ptr_ptr_child_ty.sentinel();
+ elem_ty = ptr_ptr_child_ty.childType();
},
.Pointer => switch (ptr_ptr_child_ty.ptrSize()) {
.One => {
test/cases/compile_errors/slice_of_non_array_type.zig
@@ -0,0 +1,9 @@
+comptime {
+ _ = 1[0..];
+}
+
+// error
+// backend=stage2
+// target=native
+//
+// :2:10: error: slice of non-array type 'comptime_int'