authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-03-25 17:31:22+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-03-27 20:53:06+02:00
loge444e69dc4f9e6a1f25f6081bd0cd4d45f4c9c93
tree35f7daf4092548c5cff732a7edd143c313a93944
parent4985abcc494cc545e34b164fe12de592cf1b50f4

dwarf: do not use `Type.errorSetNames()` for inferred error sets

Otherwise, we risk tripping an assertion in `Type.errorSetNames()` in case the inferred error set was not yet fully resolved. This so far only surfaced when Dwarf triggers recursive analysis of an error set as part of emitting debug info for an error union.

1 files changed, 12 insertions(+), 1 deletions(-)

src/link/Dwarf.zig+12-1
...@@ -1117,7 +1117,18 @@ fn addDbgInfoType(...@@ -1117,7 +1117,18 @@ fn addDbgInfoType(
1117 // DW.AT.const_value, DW.FORM.data81117 // DW.AT.const_value, DW.FORM.data8
1118 mem.writeInt(u64, dbg_info_buffer.addManyAsArrayAssumeCapacity(8), 0, target_endian);1118 mem.writeInt(u64, dbg_info_buffer.addManyAsArrayAssumeCapacity(8), 0, target_endian);
11191119
1120 const error_names = if (ty.isAnyError()) module.error_name_list.items else ty.errorSetNames();1120 const error_names = blk: {
1121 if (ty.isAnyError())
1122 break :blk module.error_name_list.items;
1123 // TODO not quite sure about the next one, but if I don't do this, I risk
1124 // tripping an assert in `Type.errorSetNames` in case the inferred error set
1125 // was not yet fully resolved. This so far only surfaced when this code would
1126 // schedule analysis of an error set part of some error union.
1127 if (ty.tag() == .error_set_inferred)
1128 break :blk ty.castTag(.error_set_inferred).?.data.errors.keys();
1129 break :blk ty.errorSetNames();
1130 };
1131
1121 for (error_names) |error_name| {1132 for (error_names) |error_name| {
1122 const kv = module.getErrorValue(error_name) catch unreachable;1133 const kv = module.getErrorValue(error_name) catch unreachable;
1123 // DW.AT.enumerator1134 // DW.AT.enumerator