diff --git a/src/Module.zig b/src/Module.zig index 6a33990463..b0c18def78 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -6115,6 +6115,8 @@ pub const PeerTypeCandidateSrc = union(enum) { return null; }, .override => |candidate_srcs| { + if (candidate_i >= candidate_srcs.len) + return null; return candidate_srcs[candidate_i]; }, .typeof_builtin_call_node_offset => |node_offset| { diff --git a/test/cases/compile_errors/issue_15572_break_on_inline_while.zig b/test/cases/compile_errors/issue_15572_break_on_inline_while.zig new file mode 100644 index 0000000000..a09a72fde5 --- /dev/null +++ b/test/cases/compile_errors/issue_15572_break_on_inline_while.zig @@ -0,0 +1,20 @@ +const std = @import("std"); + +pub const DwarfSection = enum { + eh_frame, + eh_frame_hdr, +}; + +pub fn main() void { + const section = inline for (@typeInfo(DwarfSection).Enum.fields) |section| { + if (std.mem.eql(u8, section.name, "eh_frame")) break section; + }; + + _ = section; +} + +// error +// backend=stage2 +// target=native +// +// :9:28: error: incompatible types: 'builtin.Type.EnumField' and 'void'