| author | |
| committer | |
| log | 32c89531b1475ce8e3b8efdf7a07745da7bc854a |
| tree | 848ea8ac81eabbe6293eacdfc16210b1d6973a99 |
| parent | 345042ecbc7fb645fd17b69df4e57ffefa5be5a5 |
| signature |
in array literals.
Fixes #35242 files changed, 17 insertions(+), 1 deletions(-)
src/ir.cpp+4-1| ... | ... | @@ -17590,7 +17590,10 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 17590 | 17590 | false); |
| 17591 | 17591 | array_ptr_val->data.x_struct.fields[slice_ptr_index].data.x_ptr.mut = ConstPtrMutInfer; |
| 17592 | 17592 | } else { |
| 17593 | zig_unreachable(); | |
| 17593 | ir_add_error(ira, elem_ptr_instruction->init_array_type, | |
| 17594 | buf_sprintf("expected array type or [_], found '%s'", | |
| 17595 | buf_ptr(&array_type->name))); | |
| 17596 | return ira->codegen->invalid_instruction; | |
| 17594 | 17597 | } |
| 17595 | 17598 | } |
| 17596 | 17599 |
test/compile_errors.zig+13| ... | ... | @@ -2,6 +2,19 @@ const tests = @import("tests.zig"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | 3 | |
| 4 | 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5 | cases.add( | |
| 6 | "using an unknown len ptr type instead of array", | |
| 7 | \\const resolutions = [*][*]const u8{ | |
| 8 | \\ c"[320 240 ]", | |
| 9 | \\ null, | |
| 10 | \\}; | |
| 11 | \\comptime { | |
| 12 | \\ _ = resolutions; | |
| 13 | \\} | |
| 14 | , | |
| 15 | "tmp.zig:1:21: error: expected array type or [_], found '[*][*]const u8'", | |
| 16 | ); | |
| 17 | ||
| 5 | 18 | cases.add( |
| 6 | 19 | "comparison with error union and error value", |
| 7 | 20 | \\export fn entry() void { |