Fix non-constant compound literals of slices

This commit is contained in:
gingerBill
2023-06-07 00:10:39 +01:00
parent ca6cef9a7d
commit 2bc5e0ebd7
4 changed files with 43 additions and 11 deletions

View File

@@ -4230,11 +4230,12 @@ gb_internal lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) {
lbValue count = {};
count.type = t_int;
unsigned len_index = lb_convert_struct_index(p->module, type, 1);
if (lb_is_const(slice)) {
unsigned indices[1] = {1};
unsigned indices[1] = {len_index};
count.value = LLVMConstExtractValue(slice.value, indices, gb_count_of(indices));
} else {
count.value = LLVMBuildExtractValue(p->builder, slice.value, 1, "");
count.value = LLVMBuildExtractValue(p->builder, slice.value, len_index, "");
}
lb_fill_slice(p, v, data, count);
}