Skip to content

Commit cc55514

Browse files
committed
compiler: work around OPV bug
This can be reverted once #23902 is fixed.
1 parent af361ee commit cc55514

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/Compilation.zig

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3549,9 +3549,12 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
35493549
const end = start + tree.tokenSlice(failed.import_token).len;
35503550
const loc = std.zig.findLineColumn(source.bytes, start);
35513551
try bundle.addRootErrorMessage(.{
3552-
.msg = switch (failed.kind) {
3553-
.file_outside_module_root => try bundle.addString("import of file outside module path"),
3554-
},
3552+
// There is currently only one field in `kind`, so uncommenting it exposes a compiler bug: #23902
3553+
//.msg = switch (failed.kind) {
3554+
// .file_outside_module_root => try bundle.addString("import of file outside module path"),
3555+
//},
3556+
.msg = try bundle.addString("import of file outside module path"),
3557+
35553558
.src_loc = try bundle.addSourceLocation(.{
35563559
.src_path = try bundle.printString("{}", .{file.path.fmt(comp)}),
35573560
.span_start = start,

src/Zcu.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ failed_imports: std.ArrayListUnmanaged(struct {
222222
file_index: File.Index,
223223
import_string: Zir.NullTerminatedString,
224224
import_token: Ast.TokenIndex,
225-
kind: enum { file_outside_module_root },
225+
// There is currently only one field in `kind`, so uncommenting it exposes a compiler bug: #23902
226+
//kind: enum { file_outside_module_root },
226227
}) = .empty,
227228
failed_exports: std.AutoArrayHashMapUnmanaged(Export.Index, *ErrorMsg) = .empty,
228229
/// If analysis failed due to a cimport error, the corresponding Clang errors

src/Zcu/PerThread.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2233,7 +2233,8 @@ pub fn computeAliveFiles(pt: Zcu.PerThread) Allocator.Error!bool {
22332233
.file_index = file_idx,
22342234
.import_string = item.data.name,
22352235
.import_token = item.data.token,
2236-
.kind = .file_outside_module_root,
2236+
// There is currently only one field in `kind`, so uncommenting it exposes a compiler bug: #23902
2237+
//.kind = .file_outside_module_root,
22372238
});
22382239
_ = zcu.alive_files.pop(); // we failed to populate `mod`/`sub_file_path`
22392240
},

0 commit comments

Comments
 (0)