authorgravatar for mason@anthropicstudios.comMason Remaley <mason@anthropicstudios.com> 2025-02-15 15:42:59-08:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-04-02 05:53:22+01:00
log06ee383da9a23016dcb25ff7cb6811e3dc2c387e
treea1f407023746af27e8338c08b34a57336ae50cc6
parent1b62a22268117340ee7a17f019df01cd39ec1421
signaturelock-open Commit is signed but in an unrecognized format.

compiler: allow `@import` of ZON without a result type

In particular, this allows importing `build.zig.zon` at comptime.

11 files changed, 301 insertions(+), 36 deletions(-)

src/InternPool.zig+1
...@@ -2136,6 +2136,7 @@ pub const Key = union(enum) {...@@ -2136,6 +2136,7 @@ pub const Key = union(enum) {
2136 /// To avoid making this key overly complex, the type-specific data is hashed by Sema.2136 /// To avoid making this key overly complex, the type-specific data is hashed by Sema.
2137 reified: struct {2137 reified: struct {
2138 /// A `reify`, `struct_init`, `struct_init_ref`, or `struct_init_anon` instruction.2138 /// A `reify`, `struct_init`, `struct_init_ref`, or `struct_init_anon` instruction.
2139 /// Alternatively, this is `main_struct_inst` of a ZON file.
2139 zir_index: TrackedInst.Index,2140 zir_index: TrackedInst.Index,
2140 /// A hash of this type's attributes, fields, etc, generated by Sema.2141 /// A hash of this type's attributes, fields, etc, generated by Sema.
2141 type_hash: u64,2142 type_hash: u64,
src/Sema.zig+9-10
...@@ -2998,7 +2998,7 @@ fn zirStructDecl(...@@ -2998,7 +2998,7 @@ fn zirStructDecl(
2998 return Air.internedToRef(wip_ty.finish(ip, new_namespace_index));2998 return Air.internedToRef(wip_ty.finish(ip, new_namespace_index));
2999}2999}
30003000
3001fn createTypeName(3001pub fn createTypeName(
3002 sema: *Sema,3002 sema: *Sema,
3003 block: *Block,3003 block: *Block,
3004 name_strategy: Zir.Inst.NameStrategy,3004 name_strategy: Zir.Inst.NameStrategy,
...@@ -14065,14 +14065,13 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -14065,14 +14065,13 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
14065 return Air.internedToRef(ty);14065 return Air.internedToRef(ty);
14066 },14066 },
14067 .zon => {14067 .zon => {
14068 if (extra.res_ty == .none) {14068 const res_ty: InternPool.Index = b: {
14069 return sema.fail(block, operand_src, "'@import' of ZON must have a known result type", .{});14069 if (extra.res_ty == .none) break :b .none;
14070 }14070 const res_ty_inst = try sema.resolveInst(extra.res_ty);
14071 const res_ty_inst = try sema.resolveInst(extra.res_ty);14071 const res_ty = try sema.analyzeAsType(block, operand_src, res_ty_inst);
14072 const res_ty = try sema.analyzeAsType(block, operand_src, res_ty_inst);14072 if (res_ty.isGenericPoison()) break :b .none;
14073 if (res_ty.isGenericPoison()) {14073 break :b res_ty.toIntern();
14074 return sema.fail(block, operand_src, "'@import' of ZON must have a known result type", .{});14074 };
14075 }
1407614075
14077 try sema.declareDependency(.{ .zon_file = result.file_index });14076 try sema.declareDependency(.{ .zon_file = result.file_index });
14078 const interned = try LowerZon.run(14077 const interned = try LowerZon.run(
...@@ -31699,7 +31698,7 @@ fn addReferenceEntry(...@@ -31699,7 +31698,7 @@ fn addReferenceEntry(
31699 try zcu.addUnitReference(sema.owner, referenced_unit, src);31698 try zcu.addUnitReference(sema.owner, referenced_unit, src);
31700}31699}
3170131700
31702fn addTypeReferenceEntry(31701pub fn addTypeReferenceEntry(
31703 sema: *Sema,31702 sema: *Sema,
31704 src: LazySrcLoc,31703 src: LazySrcLoc,
31705 referenced_type: InternPool.Index,31704 referenced_type: InternPool.Index,
src/Sema/LowerZon.zig+170-16
...@@ -33,7 +33,7 @@ pub fn run(...@@ -33,7 +33,7 @@ pub fn run(
33 sema: *Sema,33 sema: *Sema,
34 file: *File,34 file: *File,
35 file_index: Zcu.File.Index,35 file_index: Zcu.File.Index,
36 res_ty: Type,36 res_ty_interned: InternPool.Index,
37 import_loc: LazySrcLoc,37 import_loc: LazySrcLoc,
38 block: *Sema.Block,38 block: *Sema.Block,
39) CompileError!InternPool.Index {39) CompileError!InternPool.Index {
...@@ -53,13 +53,167 @@ pub fn run(...@@ -53,13 +53,167 @@ pub fn run(
53 .base_node_inst = tracked_inst,53 .base_node_inst = tracked_inst,
54 };54 };
5555
56 try lower_zon.checkType(res_ty);56 if (res_ty_interned == .none) {
57 return lower_zon.lowerExprAnonResTy(.root);
58 } else {
59 const res_ty: Type = .fromInterned(res_ty_interned);
60 try lower_zon.checkType(res_ty);
61 return lower_zon.lowerExprKnownResTy(.root, res_ty);
62 }
63}
5764
58 return lower_zon.lowerExpr(.root, res_ty);65fn lowerExprAnonResTy(self: *LowerZon, node: Zoir.Node.Index) CompileError!InternPool.Index {
66 const gpa = self.sema.gpa;
67 const pt = self.sema.pt;
68 const ip = &pt.zcu.intern_pool;
69 switch (node.get(self.file.zoir.?)) {
70 .true => return .bool_true,
71 .false => return .bool_false,
72 .null => return .null_value,
73 .pos_inf => return self.fail(node, "infinity requires a known result type", .{}),
74 .neg_inf => return self.fail(node, "negative infinity requires a known result type", .{}),
75 .nan => return self.fail(node, "NaN requires a known result type", .{}),
76 .int_literal => |int| switch (int) {
77 .small => |val| return pt.intern(.{ .int = .{
78 .ty = .comptime_int_type,
79 .storage = .{ .i64 = val },
80 } }),
81 .big => |val| return pt.intern(.{ .int = .{
82 .ty = .comptime_int_type,
83 .storage = .{ .big_int = val },
84 } }),
85 },
86 .float_literal => |val| {
87 const result = try pt.floatValue(.comptime_float, val);
88 return result.toIntern();
89 },
90 .char_literal => |val| return pt.intern(.{ .int = .{
91 .ty = .comptime_int_type,
92 .storage = .{ .i64 = val },
93 } }),
94 .enum_literal => |val| return pt.intern(.{
95 .enum_literal = try ip.getOrPutString(
96 gpa,
97 pt.tid,
98 val.get(self.file.zoir.?),
99 .no_embedded_nulls,
100 ),
101 }),
102 .string_literal => |val| {
103 const ip_str = try ip.getOrPutString(gpa, pt.tid, val, .maybe_embedded_nulls);
104 const result = try self.sema.addStrLit(ip_str, val.len);
105 return result.toInterned().?;
106 },
107 .empty_literal => return .empty_tuple,
108 .array_literal => |nodes| {
109 const types = try self.sema.arena.alloc(InternPool.Index, nodes.len);
110 const values = try self.sema.arena.alloc(InternPool.Index, nodes.len);
111 for (0..nodes.len) |i| {
112 values[i] = try self.lowerExprAnonResTy(nodes.at(@intCast(i)));
113 types[i] = Value.fromInterned(values[i]).typeOf(pt.zcu).toIntern();
114 }
115 const ty = try ip.getTupleType(
116 gpa,
117 pt.tid,
118 .{
119 .types = types,
120 .values = values,
121 },
122 );
123 return pt.intern(.{ .aggregate = .{
124 .ty = ty,
125 .storage = .{ .elems = values },
126 } });
127 },
128 .struct_literal => |init| {
129 const elems = try self.sema.arena.alloc(InternPool.Index, init.names.len);
130 for (0..init.names.len) |i| {
131 elems[i] = try self.lowerExprAnonResTy(init.vals.at(@intCast(i)));
132 }
133 const struct_ty = switch (try ip.getStructType(
134 gpa,
135 pt.tid,
136 .{
137 .layout = .auto,
138 .fields_len = @intCast(init.names.len),
139 .known_non_opv = false,
140 .requires_comptime = .no,
141 .any_comptime_fields = true,
142 .any_default_inits = true,
143 .inits_resolved = true,
144 .any_aligned_fields = false,
145 .key = .{ .reified = .{
146 .zir_index = self.base_node_inst,
147 .type_hash = hash: {
148 var hasher: std.hash.Wyhash = .init(0);
149 hasher.update(std.mem.asBytes(&node));
150 hasher.update(std.mem.sliceAsBytes(elems));
151 hasher.update(std.mem.sliceAsBytes(init.names));
152 break :hash hasher.final();
153 },
154 } },
155 },
156 false,
157 )) {
158 .wip => |wip| ty: {
159 errdefer wip.cancel(ip, pt.tid);
160 wip.setName(ip, try self.sema.createTypeName(
161 self.block,
162 .anon,
163 "struct",
164 self.base_node_inst.resolve(ip),
165 wip.index,
166 ));
167
168 const struct_type = ip.loadStructType(wip.index);
169
170 for (init.names, 0..) |name, field_idx| {
171 const name_interned = try ip.getOrPutString(
172 gpa,
173 pt.tid,
174 name.get(self.file.zoir.?),
175 .no_embedded_nulls,
176 );
177 assert(struct_type.addFieldName(ip, name_interned) == null);
178 struct_type.setFieldComptime(ip, field_idx);
179 }
180
181 @memcpy(struct_type.field_inits.get(ip), elems);
182 const types = struct_type.field_types.get(ip);
183 for (0..init.names.len) |i| {
184 types[i] = Value.fromInterned(elems[i]).typeOf(pt.zcu).toIntern();
185 }
186
187 const new_namespace_index = try pt.createNamespace(.{
188 .parent = self.block.namespace.toOptional(),
189 .owner_type = wip.index,
190 .file_scope = self.block.getFileScopeIndex(pt.zcu),
191 .generation = pt.zcu.generation,
192 });
193 try pt.zcu.comp.queueJob(.{ .resolve_type_fully = wip.index });
194 codegen_type: {
195 if (pt.zcu.comp.config.use_llvm) break :codegen_type;
196 if (self.block.ownerModule().strip) break :codegen_type;
197 try pt.zcu.comp.queueJob(.{ .codegen_type = wip.index });
198 }
199 break :ty wip.finish(ip, new_namespace_index);
200 },
201 .existing => |ty| ty,
202 };
203 try self.sema.declareDependency(.{ .interned = struct_ty });
204 try self.sema.addTypeReferenceEntry(self.nodeSrc(node), struct_ty);
205
206 return try pt.intern(.{ .aggregate = .{
207 .ty = struct_ty,
208 .storage = .{ .elems = elems },
209 } });
210 },
211 }
59}212}
60213
61/// Validate that `ty` is a valid ZON type. If not, emit a compile error.214/// Validate that `ty` is a valid ZON type, or emit a compile error.
62/// i.e. no nested optionals, no error sets, etc.215///
216/// Rules out nested optionals, error sets, etc.
63fn checkType(self: *LowerZon, ty: Type) !void {217fn checkType(self: *LowerZon, ty: Type) !void {
64 var visited: std.AutoHashMapUnmanaged(InternPool.Index, void) = .empty;218 var visited: std.AutoHashMapUnmanaged(InternPool.Index, void) = .empty;
65 try self.checkTypeInner(ty, null, &visited);219 try self.checkTypeInner(ty, null, &visited);
...@@ -201,9 +355,9 @@ fn fail(...@@ -201,9 +355,9 @@ fn fail(
201 return self.sema.failWithOwnedErrorMsg(self.block, err_msg);355 return self.sema.failWithOwnedErrorMsg(self.block, err_msg);
202}356}
203357
204fn lowerExpr(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) CompileError!InternPool.Index {358fn lowerExprKnownResTy(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) CompileError!InternPool.Index {
205 const pt = self.sema.pt;359 const pt = self.sema.pt;
206 return self.lowerExprInner(node, res_ty) catch |err| switch (err) {360 return self.lowerExprKnownResTyInner(node, res_ty) catch |err| switch (err) {
207 error.WrongType => return self.fail(361 error.WrongType => return self.fail(
208 node,362 node,
209 "expected type '{}'",363 "expected type '{}'",
...@@ -213,7 +367,7 @@ fn lowerExpr(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) CompileError!...@@ -213,7 +367,7 @@ fn lowerExpr(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) CompileError!
213 };367 };
214}368}
215369
216fn lowerExprInner(370fn lowerExprKnownResTyInner(
217 self: *LowerZon,371 self: *LowerZon,
218 node: Zoir.Node.Index,372 node: Zoir.Node.Index,
219 res_ty: Type,373 res_ty: Type,
...@@ -227,7 +381,7 @@ fn lowerExprInner(...@@ -227,7 +381,7 @@ fn lowerExprInner(
227 break :b .none;381 break :b .none;
228 } else b: {382 } else b: {
229 const child_type = res_ty.optionalChild(pt.zcu);383 const child_type = res_ty.optionalChild(pt.zcu);
230 break :b try self.lowerExprInner(node, child_type);384 break :b try self.lowerExprKnownResTyInner(node, child_type);
231 },385 },
232 },386 },
233 }),387 }),
...@@ -239,7 +393,7 @@ fn lowerExprInner(...@@ -239,7 +393,7 @@ fn lowerExprInner(
239 .base_addr = .{393 .base_addr = .{
240 .uav = .{394 .uav = .{
241 .orig_ty = res_ty.toIntern(),395 .orig_ty = res_ty.toIntern(),
242 .val = try self.lowerExprInner(node, .fromInterned(ptr_info.child)),396 .val = try self.lowerExprKnownResTyInner(node, .fromInterned(ptr_info.child)),
243 },397 },
244 },398 },
245 .byte_offset = 0,399 .byte_offset = 0,
...@@ -486,7 +640,7 @@ fn lowerArray(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool....@@ -486,7 +640,7 @@ fn lowerArray(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool.
486 );640 );
487641
488 for (0..nodes.len) |i| {642 for (0..nodes.len) |i| {
489 elems[i] = try self.lowerExpr(nodes.at(@intCast(i)), array_info.elem_type);643 elems[i] = try self.lowerExprKnownResTy(nodes.at(@intCast(i)), array_info.elem_type);
490 }644 }
491645
492 if (array_info.sentinel) |sentinel| {646 if (array_info.sentinel) |sentinel| {
...@@ -587,7 +741,7 @@ fn lowerTuple(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool....@@ -587,7 +741,7 @@ fn lowerTuple(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool.
587 );741 );
588 }742 }
589743
590 const val = try self.lowerExpr(elem_nodes.at(@intCast(i)), .fromInterned(field_types[i]));744 const val = try self.lowerExprKnownResTy(elem_nodes.at(@intCast(i)), .fromInterned(field_types[i]));
591745
592 if (elems[i] != .none and val != elems[i]) {746 if (elems[i] != .none and val != elems[i]) {
593 const elem_node = elem_nodes.at(@intCast(i));747 const elem_node = elem_nodes.at(@intCast(i));
...@@ -650,7 +804,7 @@ fn lowerStruct(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool...@@ -650,7 +804,7 @@ fn lowerStruct(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool
650 };804 };
651805
652 const field_type: Type = .fromInterned(struct_info.field_types.get(ip)[name_index]);806 const field_type: Type = .fromInterned(struct_info.field_types.get(ip)[name_index]);
653 field_values[name_index] = try self.lowerExpr(field_node, field_type);807 field_values[name_index] = try self.lowerExprKnownResTy(field_node, field_type);
654808
655 if (struct_info.comptime_bits.getBit(ip, name_index)) {809 if (struct_info.comptime_bits.getBit(ip, name_index)) {
656 const val = ip.indexToKey(field_values[name_index]);810 const val = ip.indexToKey(field_values[name_index]);
...@@ -715,7 +869,7 @@ fn lowerSlice(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool....@@ -715,7 +869,7 @@ fn lowerSlice(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool.
715 const elems = try self.sema.arena.alloc(InternPool.Index, elem_nodes.len + @intFromBool(ptr_info.sentinel != .none));869 const elems = try self.sema.arena.alloc(InternPool.Index, elem_nodes.len + @intFromBool(ptr_info.sentinel != .none));
716870
717 for (elems, 0..) |*elem, i| {871 for (elems, 0..) |*elem, i| {
718 elem.* = try self.lowerExpr(elem_nodes.at(@intCast(i)), .fromInterned(ptr_info.child));872 elem.* = try self.lowerExprKnownResTy(elem_nodes.at(@intCast(i)), .fromInterned(ptr_info.child));
719 }873 }
720874
721 if (ptr_info.sentinel != .none) {875 if (ptr_info.sentinel != .none) {
...@@ -810,7 +964,7 @@ fn lowerUnion(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool....@@ -810,7 +964,7 @@ fn lowerUnion(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool.
810 if (field_type.toIntern() == .void_type) {964 if (field_type.toIntern() == .void_type) {
811 return self.fail(field_node, "expected type 'void'", .{});965 return self.fail(field_node, "expected type 'void'", .{});
812 }966 }
813 break :b try self.lowerExpr(field_node, field_type);967 break :b try self.lowerExprKnownResTy(field_node, field_type);
814 } else b: {968 } else b: {
815 if (field_type.toIntern() != .void_type) {969 if (field_type.toIntern() != .void_type) {
816 return error.WrongType;970 return error.WrongType;
...@@ -846,7 +1000,7 @@ fn lowerVector(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool...@@ -846,7 +1000,7 @@ fn lowerVector(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool
846 }1000 }
8471001
848 for (elems, 0..) |*elem, i| {1002 for (elems, 0..) |*elem, i| {
849 elem.* = try self.lowerExpr(elem_nodes.at(@intCast(i)), .fromInterned(vector_info.child));1003 elem.* = try self.lowerExprKnownResTy(elem_nodes.at(@intCast(i)), .fromInterned(vector_info.child));
850 }1004 }
8511005
852 return self.sema.pt.intern(.{ .aggregate = .{1006 return self.sema.pt.intern(.{ .aggregate = .{
src/Type.zig+4-1
...@@ -3589,7 +3589,10 @@ pub fn typeDeclSrcLine(ty: Type, zcu: *Zcu) ?u32 {...@@ -3589,7 +3589,10 @@ pub fn typeDeclSrcLine(ty: Type, zcu: *Zcu) ?u32 {
3589 };3589 };
3590 const info = tracked.resolveFull(&zcu.intern_pool) orelse return null;3590 const info = tracked.resolveFull(&zcu.intern_pool) orelse return null;
3591 const file = zcu.fileByIndex(info.file);3591 const file = zcu.fileByIndex(info.file);
3592 const zir = file.zir.?;3592 const zir = switch (file.getMode()) {
3593 .zig => file.zir.?,
3594 .zon => return 0,
3595 };
3593 const inst = zir.instructions.get(@intFromEnum(info.inst));3596 const inst = zir.instructions.get(@intFromEnum(info.inst));
3594 return switch (inst.tag) {3597 return switch (inst.tag) {
3595 .struct_init, .struct_init_ref => zir.extraData(Zir.Inst.StructInit, inst.data.pl_node.payload_index).data.abs_line,3598 .struct_init, .struct_init_ref => zir.extraData(Zir.Inst.StructInit, inst.data.pl_node.payload_index).data.abs_line,
test/behavior/zon.zig+54
...@@ -517,3 +517,57 @@ test "recursive" {...@@ -517,3 +517,57 @@ test "recursive" {
517 const expected: Recursive = .{ .foo = &.{ .foo = null } };517 const expected: Recursive = .{ .foo = &.{ .foo = null } };
518 try expectEqualDeep(expected, @as(Recursive, @import("zon/recursive.zon")));518 try expectEqualDeep(expected, @as(Recursive, @import("zon/recursive.zon")));
519}519}
520
521test "anon" {
522 const expected = .{
523 .{
524 .bool_true = true,
525 .bool_false = false,
526 .string = "foo",
527 },
528 .{
529 null,
530 10,
531 36893488147419103232,
532 1.234,
533 'z',
534 .bar,
535 .{},
536 },
537 };
538
539 const actual = @import("zon/anon.zon");
540 try expectEqual(expected.len, actual.len);
541 try expectEqual(expected[1], actual[1]);
542 const expected_struct = expected[0];
543 const actual_struct = actual[0];
544 const expected_fields = @typeInfo(@TypeOf(expected_struct)).@"struct".fields;
545 const actual_fields = @typeInfo(@TypeOf(actual_struct)).@"struct".fields;
546 try expectEqual(expected_fields.len, actual_fields.len);
547 inline for (expected_fields) |field| {
548 try expectEqual(@field(expected_struct, field.name), @field(actual_struct, field.name));
549 }
550}
551
552test "build.zig.zon" {
553 const build = @import("zon/build.zig.zon");
554
555 try expectEqual(4, @typeInfo(@TypeOf(build)).@"struct".fields.len);
556 try expectEqualStrings("temp", build.name);
557 try expectEqualStrings("0.0.0", build.version);
558
559 const dependencies = build.dependencies;
560 try expectEqual(2, @typeInfo(@TypeOf(dependencies)).@"struct".fields.len);
561
562 const example_0 = dependencies.example_0;
563 try expectEqual(2, @typeInfo(@TypeOf(dependencies)).@"struct".fields.len);
564 try expectEqualStrings("https://example.com/foo.tar.gz", example_0.url);
565 try expectEqualStrings("...", example_0.hash);
566
567 const example_1 = dependencies.example_1;
568 try expectEqual(2, @typeInfo(@TypeOf(dependencies)).@"struct".fields.len);
569 try expectEqualStrings("../foo", example_1.path);
570 try expectEqual(false, example_1.lazy);
571
572 try expectEqual(.{ "build.zig", "build.zig.zon", "src" }, build.paths);
573}
test/behavior/zon/anon.zon created+16
...@@ -0,0 +1,16 @@
1.{
2 .{
3 .bool_true = true,
4 .bool_false = false,
5 .string = "foo",
6 },
7 .{
8 null,
9 10,
10 36893488147419103232,
11 1.234,
12 'z',
13 .bar,
14 .{},
15 },
16}
test/behavior/zon/build.zig.zon created+20
...@@ -0,0 +1,20 @@
1.{
2 // Comment
3 .name = "temp",
4 .version = "0.0.0",
5 .dependencies = .{
6 .example_0 = .{
7 .url = "https://example.com/foo.tar.gz",
8 .hash = "...",
9 },
10 .example_1 = .{
11 .path = "../foo",
12 .lazy = false,
13 },
14 },
15 .paths = .{
16 "build.zig",
17 "build.zig.zon",
18 "src",
19 },
20}
test/cases/compile_errors/@import_zon_anon_inf.zig created+9
...@@ -0,0 +1,9 @@
1export fn entry() void {
2 _ = @import("zon/inf.zon");
3}
4
5// error
6// imports=zon/inf.zon
7//
8// inf.zon:1:1: error: infinity requires a known result type
9// tmp.zig:2:17: note: imported here
test/cases/compile_errors/@import_zon_anon_nan.zig created+9
...@@ -0,0 +1,9 @@
1export fn entry() void {
2 _ = @import("zon/nan.zon");
3}
4
5// error
6// imports=zon/nan.zon
7//
8// nan.zon:1:1: error: NaN requires a known result type
9// tmp.zig:2:17: note: imported here
test/cases/compile_errors/@import_zon_anon_neg_inf.zig created+9
...@@ -0,0 +1,9 @@
1export fn entry() void {
2 _ = @import("zon/neg_inf.zon");
3}
4
5// error
6// imports=zon/neg_inf.zon
7//
8// neg_inf.zon:1:1: error: negative infinity requires a known result type
9// tmp.zig:2:17: note: imported here
test/cases/compile_errors/@import_zon_no_rt.zig deleted-9
...@@ -1,9 +0,0 @@
1export fn entry() void {
2 const f = @import("zon/simple_union.zon");
3 _ = f;
4}
5
6// error
7// imports=zon/simple_union.zon
8//
9// tmp.zig:2:23: error: '@import' of ZON must have a known result type