Skip to content

Commit e085e41

Browse files
committed
Don't emit error when import ZON result type is not known
This will now instead trip an assert, as support for the .none result type is not yet implemented
1 parent e5174c7 commit e085e41

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

src/Sema.zig

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14044,14 +14044,13 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1404414044
return Air.internedToRef(ty);
1404514045
},
1404614046
.zon => {
14047-
if (extra.res_ty == .none) {
14048-
return sema.fail(block, operand_src, "'@import' of ZON must have a known result type", .{});
14049-
}
14050-
const res_ty_inst = try sema.resolveInst(extra.res_ty);
14051-
const res_ty = try sema.analyzeAsType(block, operand_src, res_ty_inst);
14052-
if (res_ty.isGenericPoison()) {
14053-
return sema.fail(block, operand_src, "'@import' of ZON must have a known result type", .{});
14054-
}
14047+
const res_ty: InternPool.Index = b: {
14048+
if (extra.res_ty == .none) break :b .none;
14049+
const res_ty_inst = try sema.resolveInst(extra.res_ty);
14050+
const res_ty = try sema.analyzeAsType(block, operand_src, res_ty_inst);
14051+
if (res_ty.isGenericPoison()) break :b .none;
14052+
break :b res_ty.toIntern();
14053+
};
1405514054

1405614055
try sema.declareDependency(.{ .zon_file = result.file_index });
1405714056
const interned = try LowerZon.run(

src/Sema/LowerZon.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub fn run(
3333
sema: *Sema,
3434
file: *File,
3535
file_index: Zcu.File.Index,
36-
res_ty: Type,
36+
res_ty: InternPool.Index,
3737
import_loc: LazySrcLoc,
3838
block: *Sema.Block,
3939
) CompileError!InternPool.Index {
@@ -53,9 +53,9 @@ pub fn run(
5353
.base_node_inst = tracked_inst,
5454
};
5555

56-
try lower_zon.checkType(res_ty);
56+
try lower_zon.checkType(.fromInterned(res_ty));
5757

58-
return lower_zon.lowerExpr(.root, res_ty);
58+
return lower_zon.lowerExpr(.root, .fromInterned(res_ty));
5959
}
6060

6161
/// Validate that `ty` is a valid ZON type. If not, emit a compile error.

test/cases/compile_errors/@import_zon_no_rt.zig

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)