aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-08-24 20:50:43 +0300
committerVeikka Tuominen <git@vexu.eu>2022-08-24 21:31:02 +0300
commitf49dff64c64baf8be48cc987b4ed61712afabc3d (patch)
tree62b1dc0f49b146e32fc5d2561afaae8fdd7a019c /src/Sema.zig
parent1d0b729f28dd5f9341c4f4fe8ab4b25592e6834a (diff)
downloadzig-f49dff64c64baf8be48cc987b4ed61712afabc3d.tar.gz
zig-f49dff64c64baf8be48cc987b4ed61712afabc3d.zip
Sema: check one possible value earlier in `zirValidateArrayInit`
Closes #12566
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 4e1b885486..22aa26f737 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -4071,6 +4071,19 @@ fn zirValidateArrayInit(
// Determine whether the value stored to this pointer is comptime-known.
+ if (array_ty.isTuple()) {
+ if (array_ty.structFieldValueComptime(i)) |opv| {
+ element_vals[i] = opv;
+ continue;
+ }
+ } else {
+ // Array has one possible value, so value is always comptime-known
+ if (opt_opv) |opv| {
+ element_vals[i] = opv;
+ continue;
+ }
+ }
+
const elem_ptr_air_ref = sema.inst_map.get(elem_ptr).?;
const elem_ptr_air_inst = Air.refToIndex(elem_ptr_air_ref).?;
// Find the block index of the elem_ptr so that we can look at the next
@@ -4087,19 +4100,6 @@ fn zirValidateArrayInit(
}
first_block_index = @minimum(first_block_index, block_index);
- if (array_ty.isTuple()) {
- if (array_ty.structFieldValueComptime(i)) |opv| {
- element_vals[i] = opv;
- continue;
- }
- } else {
- // Array has one possible value, so value is always comptime-known
- if (opt_opv) |opv| {
- element_vals[i] = opv;
- continue;
- }
- }
-
// If the next instructon is a store with a comptime operand, this element
// is comptime.
const next_air_inst = block.instructions.items[block_index + 1];