Sema: fix crash on slice of non-array type

Closes #12621
This commit is contained in:
Veikka Tuominen 2022-08-24 20:29:13 +03:00
parent cd1833044a
commit 1d0b729f28
2 changed files with 11 additions and 1 deletions

View File

@ -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 => {

View File

@ -0,0 +1,9 @@
comptime {
_ = 1[0..];
}
// error
// backend=stage2
// target=native
//
// :2:10: error: slice of non-array type 'comptime_int'