module: return null if no candidate src

Closes #15572.
This commit is contained in:
John Schmidt 2023-05-07 22:58:15 +02:00 committed by Veikka Tuominen
parent 20cc69318f
commit 2606498409
2 changed files with 22 additions and 0 deletions

View File

@ -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| {

View File

@ -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'