From 286077fec8f381c7b4d4d5bf351d963564a1dd69 Mon Sep 17 00:00:00 2001 From: Vexu Date: Sun, 20 Dec 2020 23:28:13 +0200 Subject: [PATCH] stage1: add missing error check on inferred struct field ptr --- src/stage1/ir.cpp | 3 +++ test/compile_errors.zig | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp index 0e1c659642..9278ee7564 100644 --- a/src/stage1/ir.cpp +++ b/src/stage1/ir.cpp @@ -19980,6 +19980,9 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr result_loc = ir_analyze_struct_field_ptr(ira, suspend_source_instr, field, casted_ptr, isf->inferred_struct_type, true); + if (type_is_invalid(result_loc->value->type)) { + return result_loc; + } result_loc_pass1->resolved_loc = result_loc; } diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 3e6875698f..14462b2382 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2376,8 +2376,13 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\export fn entry() void { \\ const x = [_]u8; \\} + \\export fn entry2() void { + \\ const S = struct { a: *const [_]u8 }; + \\ var a = .{ S{} }; + \\} , &[_][]const u8{ "tmp.zig:2:15: error: inferred array size invalid here", + "tmp.zig:5:34: error: inferred array size invalid here", }); cases.add("initializing array with struct syntax",