authorgravatar for mason@gamesbymason.comMason Remaley <mason@gamesbymason.com> 2026-09-28 00:20:25-07:00
committergravatar for mason@gamesbymason.comMason Remaley <mason@gamesbymason.com> 2026-09-28 00:30:42-07:00
log58ce0f3d913dfe0cb91dc151c40128c433f41d98
tree199838982657e2af511e034638fe6ecae47c0868
parent139666586ec5a59ff4d4e6973b857c058dc9b572

Rename `Errors` to `Diagnostics` to match other uses of this pattern in std


1 files changed, 502 insertions(+), 549 deletions(-)

lib/std/zon/parse.zig+502-549
...@@ -23,82 +23,14 @@ const ArenaAllocator = std.heap.ArenaAllocator;...@@ -23,82 +23,14 @@ const ArenaAllocator = std.heap.ArenaAllocator;
23/// Rename when adding or removing support for a type.23/// Rename when adding or removing support for a type.
24const valid_types = {};24const valid_types = {};
2525
26/// An error encountered while parsing ZON.
27pub const Error = struct {
28 msg: []const u8,
29 loc: Ast.Location,
30 token: Ast.OptionalTokenIndex,
31 /// If `token == .none`, this is an `Ast.Node.Index`.
32 /// Otherwise, this is a byte offset into `token`.
33 node_or_offset: u32,
34 notes: []Note,
35
36 const Options = struct {
37 msg: []const u8,
38 token: Ast.OptionalTokenIndex,
39 node_or_offset: u32,
40 notes: []Note,
41 };
42
43 fn init(ast: *const Ast, options: Error.Options) Error {
44 return .{
45 .msg = options.msg,
46 .loc = astLoc(ast, options.token, options.node_or_offset),
47 .token = options.token,
48 .node_or_offset = options.node_or_offset,
49 .notes = options.notes,
50 };
51 }
52
53 fn astLoc(
54 ast: *const Ast,
55 maybe_token: Ast.OptionalTokenIndex,
56 node_or_offset: u32,
57 ) Ast.Location {
58 if (maybe_token.unwrap()) |token| {
59 var loc = ast.tokenLocation(0, token);
60 loc.column += node_or_offset;
61 return loc;
62 } else {
63 const ast_node: Ast.Node.Index = @fromBackingInt(@intCast(node_or_offset));
64 const token = ast.nodeMainToken(ast_node);
65 return ast.tokenLocation(0, token);
66 }
67 }
68
69 pub const Note = struct {
70 msg: []const u8,
71 loc: Ast.Location,
72 token: Ast.OptionalTokenIndex,
73 /// If `token == .none`, this is an `Ast.Node.Index`.
74 /// Otherwise, this is a byte offset into `token`.
75 node_or_offset: u32,
76
77 const Options = struct {
78 msg: []const u8,
79 token: Ast.OptionalTokenIndex,
80 node_or_offset: u32,
81 };
82
83 fn init(ast: *const Ast, options: Note.Options) @This() {
84 return .{
85 .msg = options.msg,
86 .loc = astLoc(ast, options.token, options.node_or_offset),
87 .token = options.token,
88 .node_or_offset = options.node_or_offset,
89 };
90 }
91 };
92};
93
94/// Errors encountered while parsing ZON. See `log` and `fatal` for reporting errors to the user.26/// Errors encountered while parsing ZON. See `log` and `fatal` for reporting errors to the user.
95pub const Errors = struct {27pub const Diagnostics = struct {
96 items: []const Error,28 errors: []const Error,
9729
98 pub const empty: Errors = .{ .items = &.{} };30 pub const empty: Diagnostics = .{ .errors = &.{} };
9931
100 /// Log the failure with `std.log.err`.32 /// Log the failure with `std.log.err`.
101 pub fn log(self: *const Errors, path: []const u8) void {33 pub fn log(self: *const Diagnostics, path: []const u8) void {
102 std.log.err("{f}", .{self.fmt(path)});34 std.log.err("{f}", .{self.fmt(path)});
103 }35 }
10436
...@@ -107,7 +39,7 @@ pub const Errors = struct {...@@ -107,7 +39,7 @@ pub const Errors = struct {
107 var arena_allocator: ArenaAllocator = .init(gpa);39 var arena_allocator: ArenaAllocator = .init(gpa);
108 defer arena_allocator.deinit();40 defer arena_allocator.deinit();
109 const arena = arena_allocator.allocator();41 const arena = arena_allocator.allocator();
110 var errors: Errors = .empty;42 var diagnostics: Diagnostics = .empty;
11143
112 const MyType = struct {44 const MyType = struct {
113 foo: u32,45 foo: u32,
...@@ -118,11 +50,11 @@ pub const Errors = struct {...@@ -118,11 +50,11 @@ pub const Errors = struct {
118 .gpa = gpa,50 .gpa = gpa,
119 .arena = arena,51 .arena = arena,
120 .source = ".{ .foo = 1, .bar = 2 }",52 .source = ".{ .foo = 1, .bar = 2 }",
121 .errors = &errors,53 .diagnostics = &diagnostics,
122 }) catch |err| switch (err) {54 }) catch |err| switch (err) {
123 error.OutOfMemory => return error.OutOfMemory,55 error.OutOfMemory => return error.OutOfMemory,
124 error.ParseZon => b: {56 error.ParseZon => b: {
125 errors.log("input.zon");57 diagnostics.log("input.zon");
126 break :b .{ .foo = 0, .bar = 0 };58 break :b .{ .foo = 0, .bar = 0 };
127 },59 },
128 };60 };
...@@ -130,7 +62,7 @@ pub const Errors = struct {...@@ -130,7 +62,7 @@ pub const Errors = struct {
130 }62 }
13163
132 /// Log the failure with `std.log.err`, and then terminate the process with exit code 1.64 /// Log the failure with `std.log.err`, and then terminate the process with exit code 1.
133 pub fn fatal(self: *const Errors, path: []const u8) noreturn {65 pub fn fatal(self: *const Diagnostics, path: []const u8) noreturn {
134 std.process.fatal("{f}", .{self.fmt(path)});66 std.process.fatal("{f}", .{self.fmt(path)});
135 }67 }
13668
...@@ -139,7 +71,7 @@ pub const Errors = struct {...@@ -139,7 +71,7 @@ pub const Errors = struct {
139 var arena_allocator: ArenaAllocator = .init(gpa);71 var arena_allocator: ArenaAllocator = .init(gpa);
140 defer arena_allocator.deinit();72 defer arena_allocator.deinit();
141 const arena = arena_allocator.allocator();73 const arena = arena_allocator.allocator();
142 var errors: Errors = .empty;74 var diagnostics: Diagnostics = .empty;
14375
144 const MyType = struct {76 const MyType = struct {
145 foo: u32,77 foo: u32,
...@@ -150,27 +82,44 @@ pub const Errors = struct {...@@ -150,27 +82,44 @@ pub const Errors = struct {
150 .gpa = gpa,82 .gpa = gpa,
151 .arena = arena,83 .arena = arena,
152 .source = ".{ .foo = 1, .bar = 2 }",84 .source = ".{ .foo = 1, .bar = 2 }",
153 .errors = &errors,85 .diagnostics = &diagnostics,
154 }) catch |err| switch (err) {86 }) catch |err| switch (err) {
155 error.OutOfMemory => return error.OutOfMemory,87 error.OutOfMemory => return error.OutOfMemory,
156 error.ParseZon => errors.fatal("input.zon"),88 error.ParseZon => diagnostics.fatal("input.zon"),
157 };89 };
158 _ = parsed;90 _ = parsed;
159 }91 }
16092
161 pub fn fmt(self: *const Errors, path: []const u8) Formatter {93 /// Formats a human readable description of any errors.
94 pub fn fmt(self: *const Diagnostics, path: []const u8) Formatter {
162 return .{95 return .{
163 .items = self.items,96 .errors = self.errors,
164 .path = path,97 .path = path,
165 };98 };
166 }99 }
167100
101 fn astLoc(
102 ast: *const Ast,
103 maybe_token: Ast.OptionalTokenIndex,
104 node_or_offset: u32,
105 ) Ast.Location {
106 if (maybe_token.unwrap()) |token| {
107 var loc = ast.tokenLocation(0, token);
108 loc.column += node_or_offset;
109 return loc;
110 } else {
111 const ast_node: Ast.Node.Index = @fromBackingInt(@intCast(node_or_offset));
112 const token = ast.nodeMainToken(ast_node);
113 return ast.tokenLocation(0, token);
114 }
115 }
116
168 pub const Formatter = struct {117 pub const Formatter = struct {
169 path: []const u8,118 path: []const u8,
170 items: []const Error,119 errors: []const Error,
171120
172 pub fn format(self: *const @This(), w: *std.Io.Writer) std.Io.Writer.Error!void {121 pub fn format(self: *const @This(), w: *std.Io.Writer) std.Io.Writer.Error!void {
173 for (self.items) |e| {122 for (self.errors) |e| {
174 try w.print("{s}:", .{self.path});123 try w.print("{s}:", .{self.path});
175 try w.print("{d}:{d}: error: {s}\n", .{124 try w.print("{d}:{d}: error: {s}\n", .{
176 e.loc.line + 1,125 e.loc.line + 1,
...@@ -189,23 +138,74 @@ pub const Errors = struct {...@@ -189,23 +138,74 @@ pub const Errors = struct {
189 }138 }
190 }139 }
191 };140 };
141
142 pub const Error = struct {
143 msg: []const u8,
144 loc: Ast.Location,
145 token: Ast.OptionalTokenIndex,
146 /// If `token == .none`, this is an `Ast.Node.Index`.
147 /// Otherwise, this is a byte offset into `token`.
148 node_or_offset: u32,
149 notes: []Note,
150
151 const Options = struct {
152 msg: []const u8,
153 token: Ast.OptionalTokenIndex,
154 node_or_offset: u32,
155 notes: []Note,
156 };
157
158 fn init(ast: *const Ast, options: Error.Options) Error {
159 return .{
160 .msg = options.msg,
161 .loc = astLoc(ast, options.token, options.node_or_offset),
162 .token = options.token,
163 .node_or_offset = options.node_or_offset,
164 .notes = options.notes,
165 };
166 }
167 };
168
169 pub const Note = struct {
170 msg: []const u8,
171 loc: Ast.Location,
172 token: Ast.OptionalTokenIndex,
173 /// If `token == .none`, this is an `Ast.Node.Index`.
174 /// Otherwise, this is a byte offset into `token`.
175 node_or_offset: u32,
176
177 const Options = struct {
178 msg: []const u8,
179 token: Ast.OptionalTokenIndex,
180 node_or_offset: u32,
181 };
182
183 fn init(ast: *const Ast, options: Note.Options) @This() {
184 return .{
185 .msg = options.msg,
186 .loc = astLoc(ast, options.token, options.node_or_offset),
187 .token = options.token,
188 .node_or_offset = options.node_or_offset,
189 };
190 }
191 };
192};192};
193193
194pub const Options = struct {194pub const Options = struct {
195 /// Used for scratch allocations.195 /// Used for scratch allocations.
196 gpa: Allocator,196 gpa: Allocator,
197 /// Used for allocating errors and results.197 /// Used for allocating diagnostics and results.
198 arena: Allocator,198 arena: Allocator,
199 /// The ZON source to parse.199 /// The ZON source to parse.
200 source: [:0]const u8,200 source: [:0]const u8,
201 /// When an error is returned from the parser, a human readable error description of the failure201 /// When an error is returned from the parser, a human readable error description of the failure
202 /// is stored here.202 /// is stored here.
203 errors: *Errors,203 diagnostics: *Diagnostics,
204 /// If true, unknown fields do not error.204 /// If true, unknown fields do not error.
205 ignore_unknown_fields: bool = false,205 ignore_unknown_fields: bool = false,
206};206};
207207
208/// Parses the given slice as ZON, writing any errors to `options.errors`.208/// Parses the given slice as ZON, writing any errors to `options.diagnostics`.
209pub fn fromSlice(T: type, options: Options) error{ OutOfMemory, ParseZon }!T {209pub fn fromSlice(T: type, options: Options) error{ OutOfMemory, ParseZon }!T {
210 var value: T = undefined;210 var value: T = undefined;
211 try fromSliceInner(T, &value, false, options);211 try fromSliceInner(T, &value, false, options);
...@@ -232,16 +232,16 @@ test fromSlice {...@@ -232,16 +232,16 @@ test fromSlice {
232 \\}232 \\}
233 ;233 ;
234234
235 var errors: Errors = .empty;235 var diagnostics: Diagnostics = .empty;
236 const options = fromSlice(TextureOptions, .{236 const options = fromSlice(TextureOptions, .{
237 .gpa = gpa,237 .gpa = gpa,
238 .arena = arena,238 .arena = arena,
239 .source = source,239 .source = source,
240 .errors = &errors,240 .diagnostics = &diagnostics,
241 }) catch |err| switch (err) {241 }) catch |err| switch (err) {
242 error.OutOfMemory => return err,242 error.OutOfMemory => return err,
243 error.ParseZon => {243 error.ParseZon => {
244 errors.log("texture_options.zon");244 diagnostics.log("texture_options.zon");
245 return err;245 return err;
246 },246 },
247 };247 };
...@@ -307,16 +307,16 @@ test updateFromSlice {...@@ -307,16 +307,16 @@ test updateFromSlice {
307 .theme = "default",307 .theme = "default",
308 };308 };
309309
310 var errors: Errors = .empty;310 var diagnostics: Diagnostics = .empty;
311 updateFromSlice(MyTextEditorConfig, &config, .{311 updateFromSlice(MyTextEditorConfig, &config, .{
312 .gpa = gpa,312 .gpa = gpa,
313 .arena = arena,313 .arena = arena,
314 .source = global_config,314 .source = global_config,
315 .errors = &errors,315 .diagnostics = &diagnostics,
316 }) catch |err| switch (err) {316 }) catch |err| switch (err) {
317 error.OutOfMemory => return err,317 error.OutOfMemory => return err,
318 error.ParseZon => {318 error.ParseZon => {
319 errors.log("global_config.zon");319 diagnostics.log("global_config.zon");
320 return err;320 return err;
321 },321 },
322 };322 };
...@@ -324,11 +324,11 @@ test updateFromSlice {...@@ -324,11 +324,11 @@ test updateFromSlice {
324 .gpa = gpa,324 .gpa = gpa,
325 .arena = arena,325 .arena = arena,
326 .source = project_config,326 .source = project_config,
327 .errors = &errors,327 .diagnostics = &diagnostics,
328 }) catch |err| switch (err) {328 }) catch |err| switch (err) {
329 error.OutOfMemory => return err,329 error.OutOfMemory => return err,
330 error.ParseZon => {330 error.ParseZon => {
331 errors.log("project_config.zon");331 diagnostics.log("project_config.zon");
332 return err;332 return err;
333 },333 },
334 };334 };
...@@ -358,8 +358,8 @@ fn fromSliceInner(...@@ -358,8 +358,8 @@ fn fromSliceInner(
358 initialized: bool,358 initialized: bool,
359 options: Options,359 options: Options,
360) error{ OutOfMemory, ParseZon }!void {360) error{ OutOfMemory, ParseZon }!void {
361 var errors: std.ArrayList(Error) = .empty;361 var errors: std.ArrayList(Diagnostics.Error) = .empty;
362 defer options.errors.items = errors.items;362 defer options.diagnostics.errors = errors.items;
363363
364 var ast = try std.zig.Ast.parse(options.gpa, options.source, .{ .mode = .zon });364 var ast = try std.zig.Ast.parse(options.gpa, options.source, .{ .mode = .zon });
365 defer ast.deinit(options.gpa);365 defer ast.deinit(options.gpa);
...@@ -378,7 +378,7 @@ fn fromSliceInner(...@@ -378,7 +378,7 @@ fn fromSliceInner(
378}378}
379379
380pub const FromZoirOptions = struct {380pub const FromZoirOptions = struct {
381 /// Used for allocating errors and results.381 /// Used for allocating diagnostics and results.
382 arena: Allocator,382 arena: Allocator,
383 /// The AST for this ZON value.383 /// The AST for this ZON value.
384 ast: *const Ast,384 ast: *const Ast,
...@@ -388,7 +388,7 @@ pub const FromZoirOptions = struct {...@@ -388,7 +388,7 @@ pub const FromZoirOptions = struct {
388 node: Zoir.Node.Index = .root,388 node: Zoir.Node.Index = .root,
389 /// When an error is returned from the parser, a human readable error description of the failure389 /// When an error is returned from the parser, a human readable error description of the failure
390 /// is stored here.390 /// is stored here.
391 errors: *Errors,391 diagnostics: *Diagnostics,
392 /// If true, unknown fields do not error.392 /// If true, unknown fields do not error.
393 ignore_unknown_fields: bool = false,393 ignore_unknown_fields: bool = false,
394};394};
...@@ -431,8 +431,8 @@ fn fromZoirInner(...@@ -431,8 +431,8 @@ fn fromZoirInner(
431 initialized: bool,431 initialized: bool,
432 options: FromZoirOptions,432 options: FromZoirOptions,
433) error{ OutOfMemory, ParseZon }!void {433) error{ OutOfMemory, ParseZon }!void {
434 var errors: std.ArrayList(Error) = .empty;434 var errors: std.ArrayList(Diagnostics.Error) = .empty;
435 defer options.errors.items = errors.items;435 defer options.diagnostics.errors = errors.items;
436 return inner(T, value, initialized, .{436 return inner(T, value, initialized, .{
437 .arena = options.arena,437 .arena = options.arena,
438 .ast = options.ast,438 .ast = options.ast,
...@@ -447,7 +447,7 @@ const InnerOptions = struct {...@@ -447,7 +447,7 @@ const InnerOptions = struct {
447 ast: *const Ast,447 ast: *const Ast,
448 zoir: *const Zoir,448 zoir: *const Zoir,
449 node: Zoir.Node.Index = .root,449 node: Zoir.Node.Index = .root,
450 errors: *std.ArrayList(Error),450 errors: *std.ArrayList(Diagnostics.Error),
451 ignore_unknown_fields: bool,451 ignore_unknown_fields: bool,
452};452};
453453
...@@ -461,7 +461,7 @@ fn inner(...@@ -461,7 +461,7 @@ fn inner(
461461
462 if (options.zoir.hasCompileErrors()) {462 if (options.zoir.hasCompileErrors()) {
463 for (options.zoir.compile_errors) |e| {463 for (options.zoir.compile_errors) |e| {
464 var notes: std.ArrayList(Error.Note) = .empty;464 var notes: std.ArrayList(Diagnostics.Note) = .empty;
465 for (e.getNotes(options.zoir)) |note| {465 for (e.getNotes(options.zoir)) |note| {
466 try notes.append(options.arena, .init(options.ast, .{466 try notes.append(options.arena, .init(options.ast, .{
467 .msg = try options.arena.dupe(u8, note.msg.get(options.zoir)),467 .msg = try options.arena.dupe(u8, note.msg.get(options.zoir)),
...@@ -515,7 +515,7 @@ const Parser = struct {...@@ -515,7 +515,7 @@ const Parser = struct {
515 arena: Allocator,515 arena: Allocator,
516 ast: *const Ast,516 ast: *const Ast,
517 zoir: *const Zoir,517 zoir: *const Zoir,
518 errors: *std.ArrayList(Error),518 errors: *std.ArrayList(Diagnostics.Error),
519 ignore_unknown_fields: bool,519 ignore_unknown_fields: bool,
520520
521 const ParseExprError = error{ ParseZon, OutOfMemory };521 const ParseExprError = error{ ParseZon, OutOfMemory };
...@@ -1086,7 +1086,7 @@ const Parser = struct {...@@ -1086,7 +1086,7 @@ const Parser = struct {
1086 offset: u32,1086 offset: u32,
1087 comptime fmt: []const u8,1087 comptime fmt: []const u8,
1088 args: anytype,1088 args: anytype,
1089 notes: []Error.Note,1089 notes: []Diagnostics.Note,
1090 ) error{ OutOfMemory, ParseZon } {1090 ) error{ OutOfMemory, ParseZon } {
1091 @branchHint(.cold);1091 @branchHint(.cold);
1092 comptime assert(args.len > 0);1092 comptime assert(args.len > 0);
...@@ -1112,7 +1112,7 @@ const Parser = struct {...@@ -1112,7 +1112,7 @@ const Parser = struct {
11121112
1113 fn failToken(1113 fn failToken(
1114 self: Parser,1114 self: Parser,
1115 failure: Error,1115 failure: Diagnostics.Error,
1116 ) error{ OutOfMemory, ParseZon } {1116 ) error{ OutOfMemory, ParseZon } {
1117 @branchHint(.cold);1117 @branchHint(.cold);
1118 try self.errors.append(self.arena, failure);1118 try self.errors.append(self.arena, failure);
...@@ -1160,7 +1160,7 @@ const Parser = struct {...@@ -1160,7 +1160,7 @@ const Parser = struct {
1160 } else self.ast.nodeMainToken(node.getAstNode(self.zoir));1160 } else self.ast.nodeMainToken(node.getAstNode(self.zoir));
1161 switch (@typeInfo(T)) {1161 switch (@typeInfo(T)) {
1162 inline .@"struct", .@"union", .@"enum" => |info| {1162 inline .@"struct", .@"union", .@"enum" => |info| {
1163 var notes: std.ArrayList(Error.Note) = .empty;1163 var notes: std.ArrayList(Diagnostics.Note) = .empty;
1164 if (info.field_names.len == 0) {1164 if (info.field_names.len == 0) {
1165 try notes.append(self.arena, .init(self.ast, .{1165 try notes.append(self.arena, .init(self.ast, .{
1166 .token = .fromToken(token),1166 .token = .fromToken(token),
...@@ -1384,20 +1384,20 @@ test "std.zon ast errors" {...@@ -1384,20 +1384,20 @@ test "std.zon ast errors" {
1384 var arena_allocator: ArenaAllocator = .init(gpa);1384 var arena_allocator: ArenaAllocator = .init(gpa);
1385 defer arena_allocator.deinit();1385 defer arena_allocator.deinit();
1386 const arena = arena_allocator.allocator();1386 const arena = arena_allocator.allocator();
1387 var errors: Errors = .empty;1387 var diagnostics: Diagnostics = .empty;
1388 try std.testing.expectError(1388 try std.testing.expectError(
1389 error.ParseZon,1389 error.ParseZon,
1390 fromSliceNoAlloc(struct {}, .{1390 fromSliceNoAlloc(struct {}, .{
1391 .gpa = gpa,1391 .gpa = gpa,
1392 .arena = arena,1392 .arena = arena,
1393 .source = ".{.x = 1 .y = 2}",1393 .source = ".{.x = 1 .y = 2}",
1394 .errors = &errors,1394 .diagnostics = &diagnostics,
1395 }),1395 }),
1396 );1396 );
1397 try std.testing.expectFmt(1397 try std.testing.expectFmt(
1398 \\input.zon:1:13: error: expected ',' after initializer1398 \\input.zon:1:13: error: expected ',' after initializer
1399 \\1399 \\
1400 , "{f}", .{errors.fmt("input.zon")});1400 , "{f}", .{diagnostics.fmt("input.zon")});
1401}1401}
14021402
1403test "std.zon comments" {1403test "std.zon comments" {
...@@ -1405,7 +1405,7 @@ test "std.zon comments" {...@@ -1405,7 +1405,7 @@ test "std.zon comments" {
1405 var arena_allocator: ArenaAllocator = .init(gpa);1405 var arena_allocator: ArenaAllocator = .init(gpa);
1406 defer arena_allocator.deinit();1406 defer arena_allocator.deinit();
1407 const arena = arena_allocator.allocator();1407 const arena = arena_allocator.allocator();
1408 var errors: Errors = .empty;1408 var diagnostics: Diagnostics = .empty;
14091409
1410 try std.testing.expectEqual(@as(u8, 10), fromSliceNoAlloc(u8, .{1410 try std.testing.expectEqual(@as(u8, 10), fromSliceNoAlloc(u8, .{
1411 .gpa = gpa,1411 .gpa = gpa,
...@@ -1415,7 +1415,7 @@ test "std.zon comments" {...@@ -1415,7 +1415,7 @@ test "std.zon comments" {
1415 \\10 // comment1415 \\10 // comment
1416 \\// comment1416 \\// comment
1417 ,1417 ,
1418 .errors = &errors,1418 .diagnostics = &diagnostics,
1419 }));1419 }));
14201420
1421 {1421 {
...@@ -1427,12 +1427,12 @@ test "std.zon comments" {...@@ -1427,12 +1427,12 @@ test "std.zon comments" {
1427 \\10 // comment1427 \\10 // comment
1428 \\// comment1428 \\// comment
1429 ,1429 ,
1430 .errors = &errors,1430 .diagnostics = &diagnostics,
1431 }));1431 }));
1432 try std.testing.expectFmt(1432 try std.testing.expectFmt(
1433 \\input.zon:1:1: error: expected expression, found 'a document comment'1433 \\input.zon:1:1: error: expected expression, found 'a document comment'
1434 \\1434 \\
1435 , "{f}", .{errors.fmt("input.zon")});1435 , "{f}", .{diagnostics.fmt("input.zon")});
1436 }1436 }
1437}1437}
14381438
...@@ -1441,17 +1441,17 @@ test "std.zon failure/oom formatting" {...@@ -1441,17 +1441,17 @@ test "std.zon failure/oom formatting" {
1441 var arena_allocator: ArenaAllocator = .init(gpa);1441 var arena_allocator: ArenaAllocator = .init(gpa);
1442 defer arena_allocator.deinit();1442 defer arena_allocator.deinit();
1443 const arena = arena_allocator.allocator();1443 const arena = arena_allocator.allocator();
1444 var errors: Errors = .empty;1444 var diagnostics: Diagnostics = .empty;
14451445
1446 try std.testing.expectError(error.OutOfMemory, fromSlice([]const u8, .{1446 try std.testing.expectError(error.OutOfMemory, fromSlice([]const u8, .{
1447 .gpa = .failing,1447 .gpa = .failing,
1448 .arena = arena,1448 .arena = arena,
1449 .source = "\"foo\"",1449 .source = "\"foo\"",
1450 .errors = &errors,1450 .diagnostics = &diagnostics,
1451 }));1451 }));
1452 try std.testing.expectFmt(1452 try std.testing.expectFmt(
1453 \\1453 \\
1454 , "{f}", .{errors.fmt("input.zon")});1454 , "{f}", .{diagnostics.fmt("input.zon")});
1455}1455}
14561456
1457test "std.zon fromSlice syntax error" {1457test "std.zon fromSlice syntax error" {
...@@ -1459,20 +1459,20 @@ test "std.zon fromSlice syntax error" {...@@ -1459,20 +1459,20 @@ test "std.zon fromSlice syntax error" {
1459 var arena_allocator: ArenaAllocator = .init(gpa);1459 var arena_allocator: ArenaAllocator = .init(gpa);
1460 defer arena_allocator.deinit();1460 defer arena_allocator.deinit();
1461 const arena = arena_allocator.allocator();1461 const arena = arena_allocator.allocator();
1462 var errors: Errors = .empty;1462 var diagnostics: Diagnostics = .empty;
1463 try std.testing.expectError(1463 try std.testing.expectError(
1464 error.ParseZon,1464 error.ParseZon,
1465 fromSliceNoAlloc(u8, .{1465 fromSliceNoAlloc(u8, .{
1466 .gpa = gpa,1466 .gpa = gpa,
1467 .arena = arena,1467 .arena = arena,
1468 .source = ".{",1468 .source = ".{",
1469 .errors = &errors,1469 .diagnostics = &diagnostics,
1470 }),1470 }),
1471 );1471 );
1472 try std.testing.expectFmt(1472 try std.testing.expectFmt(
1473 \\input.zon:1:3: error: expected expression, found 'EOF'1473 \\input.zon:1:3: error: expected expression, found 'EOF'
1474 \\1474 \\
1475 , "{f}", .{errors.fmt("input.zon")});1475 , "{f}", .{diagnostics.fmt("input.zon")});
1476}1476}
14771477
1478test "std.zon optional" {1478test "std.zon optional" {
...@@ -1480,7 +1480,7 @@ test "std.zon optional" {...@@ -1480,7 +1480,7 @@ test "std.zon optional" {
1480 var arena_allocator: ArenaAllocator = .init(gpa);1480 var arena_allocator: ArenaAllocator = .init(gpa);
1481 defer arena_allocator.deinit();1481 defer arena_allocator.deinit();
1482 const arena = arena_allocator.allocator();1482 const arena = arena_allocator.allocator();
1483 var errors: Errors = .empty;1483 var diagnostics: Diagnostics = .empty;
14841484
1485 // Basic usage1485 // Basic usage
1486 {1486 {
...@@ -1488,14 +1488,14 @@ test "std.zon optional" {...@@ -1488,14 +1488,14 @@ test "std.zon optional" {
1488 .gpa = gpa,1488 .gpa = gpa,
1489 .arena = arena,1489 .arena = arena,
1490 .source = "null",1490 .source = "null",
1491 .errors = &errors,1491 .diagnostics = &diagnostics,
1492 });1492 });
1493 try std.testing.expect(none == null);1493 try std.testing.expect(none == null);
1494 const some = try fromSliceNoAlloc(?u32, .{1494 const some = try fromSliceNoAlloc(?u32, .{
1495 .gpa = gpa,1495 .gpa = gpa,
1496 .arena = arena,1496 .arena = arena,
1497 .source = "1",1497 .source = "1",
1498 .errors = &errors,1498 .diagnostics = &diagnostics,
1499 });1499 });
1500 try std.testing.expect(some.? == 1);1500 try std.testing.expect(some.? == 1);
1501 }1501 }
...@@ -1506,14 +1506,14 @@ test "std.zon optional" {...@@ -1506,14 +1506,14 @@ test "std.zon optional" {
1506 .gpa = gpa,1506 .gpa = gpa,
1507 .arena = arena,1507 .arena = arena,
1508 .source = "null",1508 .source = "null",
1509 .errors = &errors,1509 .diagnostics = &diagnostics,
1510 });1510 });
1511 try std.testing.expect(none == null);1511 try std.testing.expect(none == null);
1512 const some = try fromSlice(?[]const u8, .{1512 const some = try fromSlice(?[]const u8, .{
1513 .gpa = gpa,1513 .gpa = gpa,
1514 .arena = arena,1514 .arena = arena,
1515 .source = "\"foo\"",1515 .source = "\"foo\"",
1516 .errors = &errors,1516 .diagnostics = &diagnostics,
1517 });1517 });
1518 try std.testing.expectEqualStrings("foo", some.?);1518 try std.testing.expectEqualStrings("foo", some.?);
1519 }1519 }
...@@ -1524,7 +1524,7 @@ test "std.zon unions" {...@@ -1524,7 +1524,7 @@ test "std.zon unions" {
1524 var arena_allocator: ArenaAllocator = .init(gpa);1524 var arena_allocator: ArenaAllocator = .init(gpa);
1525 defer arena_allocator.deinit();1525 defer arena_allocator.deinit();
1526 const arena = arena_allocator.allocator();1526 const arena = arena_allocator.allocator();
1527 var errors: Errors = .empty;1527 var diagnostics: Diagnostics = .empty;
15281528
1529 // Unions1529 // Unions
1530 {1530 {
...@@ -1535,28 +1535,28 @@ test "std.zon unions" {...@@ -1535,28 +1535,28 @@ test "std.zon unions" {
1535 .gpa = gpa,1535 .gpa = gpa,
1536 .arena = arena,1536 .arena = arena,
1537 .source = ".{.x = 1.5}",1537 .source = ".{.x = 1.5}",
1538 .errors = &errors,1538 .diagnostics = &diagnostics,
1539 });1539 });
1540 try std.testing.expectEqual(Tagged{ .x = 1.5 }, tagged_x);1540 try std.testing.expectEqual(Tagged{ .x = 1.5 }, tagged_x);
1541 const tagged_y = try fromSliceNoAlloc(Tagged, .{1541 const tagged_y = try fromSliceNoAlloc(Tagged, .{
1542 .gpa = gpa,1542 .gpa = gpa,
1543 .arena = arena,1543 .arena = arena,
1544 .source = ".{.@\"y y\" = true}",1544 .source = ".{.@\"y y\" = true}",
1545 .errors = &errors,1545 .diagnostics = &diagnostics,
1546 });1546 });
1547 try std.testing.expectEqual(Tagged{ .@"y y" = true }, tagged_y);1547 try std.testing.expectEqual(Tagged{ .@"y y" = true }, tagged_y);
1548 const tagged_z_shorthand = try fromSliceNoAlloc(Tagged, .{1548 const tagged_z_shorthand = try fromSliceNoAlloc(Tagged, .{
1549 .gpa = gpa,1549 .gpa = gpa,
1550 .arena = arena,1550 .arena = arena,
1551 .source = ".z",1551 .source = ".z",
1552 .errors = &errors,1552 .diagnostics = &diagnostics,
1553 });1553 });
1554 try std.testing.expectEqual(@as(Tagged, .z), tagged_z_shorthand);1554 try std.testing.expectEqual(@as(Tagged, .z), tagged_z_shorthand);
1555 const tagged_zz_shorthand = try fromSliceNoAlloc(Tagged, .{1555 const tagged_zz_shorthand = try fromSliceNoAlloc(Tagged, .{
1556 .gpa = gpa,1556 .gpa = gpa,
1557 .arena = arena,1557 .arena = arena,
1558 .source = ".@\"z z\"",1558 .source = ".@\"z z\"",
1559 .errors = &errors,1559 .diagnostics = &diagnostics,
1560 });1560 });
1561 try std.testing.expectEqual(@as(Tagged, .@"z z"), tagged_zz_shorthand);1561 try std.testing.expectEqual(@as(Tagged, .@"z z"), tagged_zz_shorthand);
15621562
...@@ -1564,14 +1564,14 @@ test "std.zon unions" {...@@ -1564,14 +1564,14 @@ test "std.zon unions" {
1564 .gpa = gpa,1564 .gpa = gpa,
1565 .arena = arena,1565 .arena = arena,
1566 .source = ".{.x = 1.5}",1566 .source = ".{.x = 1.5}",
1567 .errors = &errors,1567 .diagnostics = &diagnostics,
1568 });1568 });
1569 try std.testing.expect(untagged_x.x == 1.5);1569 try std.testing.expect(untagged_x.x == 1.5);
1570 const untagged_y = try fromSliceNoAlloc(Untagged, .{1570 const untagged_y = try fromSliceNoAlloc(Untagged, .{
1571 .gpa = gpa,1571 .gpa = gpa,
1572 .arena = arena,1572 .arena = arena,
1573 .source = ".{.@\"y y\" = true}",1573 .source = ".{.@\"y y\" = true}",
1574 .errors = &errors,1574 .diagnostics = &diagnostics,
1575 });1575 });
1576 try std.testing.expect(untagged_y.@"y y");1576 try std.testing.expect(untagged_y.@"y y");
1577 }1577 }
...@@ -1584,7 +1584,7 @@ test "std.zon unions" {...@@ -1584,7 +1584,7 @@ test "std.zon unions" {
1584 .gpa = gpa,1584 .gpa = gpa,
1585 .arena = arena,1585 .arena = arena,
1586 .source = ".{.baz = false}",1586 .source = ".{.baz = false}",
1587 .errors = &errors,1587 .diagnostics = &diagnostics,
1588 });1588 });
1589 try std.testing.expectEqual(Union{ .baz = false }, noalloc);1589 try std.testing.expectEqual(Union{ .baz = false }, noalloc);
15901590
...@@ -1592,7 +1592,7 @@ test "std.zon unions" {...@@ -1592,7 +1592,7 @@ test "std.zon unions" {
1592 .gpa = gpa,1592 .gpa = gpa,
1593 .arena = arena,1593 .arena = arena,
1594 .source = ".{.bar = \"qux\"}",1594 .source = ".{.bar = \"qux\"}",
1595 .errors = &errors,1595 .diagnostics = &diagnostics,
1596 });1596 });
1597 try std.testing.expectEqualDeep(Union{ .bar = "qux" }, alloc);1597 try std.testing.expectEqualDeep(Union{ .bar = "qux" }, alloc);
1598 }1598 }
...@@ -1606,14 +1606,14 @@ test "std.zon unions" {...@@ -1606,14 +1606,14 @@ test "std.zon unions" {
1606 .gpa = gpa,1606 .gpa = gpa,
1607 .arena = arena,1607 .arena = arena,
1608 .source = ".{.z=2.5}",1608 .source = ".{.z=2.5}",
1609 .errors = &errors,1609 .diagnostics = &diagnostics,
1610 }),1610 }),
1611 );1611 );
1612 try std.testing.expectFmt(1612 try std.testing.expectFmt(
1613 \\input.zon:1:4: error: unexpected field 'z'1613 \\input.zon:1:4: error: unexpected field 'z'
1614 \\input.zon:1:4: note: supported: 'x', 'y'1614 \\input.zon:1:4: note: supported: 'x', 'y'
1615 \\1615 \\
1616 , "{f}", .{errors.fmt("input.zon")});1616 , "{f}", .{diagnostics.fmt("input.zon")});
1617 }1617 }
16181618
1619 // Explicit void field1619 // Explicit void field
...@@ -1625,13 +1625,13 @@ test "std.zon unions" {...@@ -1625,13 +1625,13 @@ test "std.zon unions" {
1625 .gpa = gpa,1625 .gpa = gpa,
1626 .arena = arena,1626 .arena = arena,
1627 .source = ".{.x=1}",1627 .source = ".{.x=1}",
1628 .errors = &errors,1628 .diagnostics = &diagnostics,
1629 }),1629 }),
1630 );1630 );
1631 try std.testing.expectFmt(1631 try std.testing.expectFmt(
1632 \\input.zon:1:6: error: expected type 'void'1632 \\input.zon:1:6: error: expected type 'void'
1633 \\1633 \\
1634 , "{f}", .{errors.fmt("input.zon")});1634 , "{f}", .{diagnostics.fmt("input.zon")});
1635 }1635 }
16361636
1637 // Extra field1637 // Extra field
...@@ -1643,13 +1643,13 @@ test "std.zon unions" {...@@ -1643,13 +1643,13 @@ test "std.zon unions" {
1643 .gpa = gpa,1643 .gpa = gpa,
1644 .arena = arena,1644 .arena = arena,
1645 .source = ".{.x = 1.5, .y = true}",1645 .source = ".{.x = 1.5, .y = true}",
1646 .errors = &errors,1646 .diagnostics = &diagnostics,
1647 }),1647 }),
1648 );1648 );
1649 try std.testing.expectFmt(1649 try std.testing.expectFmt(
1650 \\input.zon:1:2: error: expected union1650 \\input.zon:1:2: error: expected union
1651 \\1651 \\
1652 , "{f}", .{errors.fmt("input.zon")});1652 , "{f}", .{diagnostics.fmt("input.zon")});
1653 }1653 }
16541654
1655 // No fields1655 // No fields
...@@ -1661,13 +1661,13 @@ test "std.zon unions" {...@@ -1661,13 +1661,13 @@ test "std.zon unions" {
1661 .gpa = gpa,1661 .gpa = gpa,
1662 .arena = arena,1662 .arena = arena,
1663 .source = ".{}",1663 .source = ".{}",
1664 .errors = &errors,1664 .diagnostics = &diagnostics,
1665 }),1665 }),
1666 );1666 );
1667 try std.testing.expectFmt(1667 try std.testing.expectFmt(
1668 \\input.zon:1:2: error: expected union1668 \\input.zon:1:2: error: expected union
1669 \\1669 \\
1670 , "{f}", .{errors.fmt("input.zon")});1670 , "{f}", .{diagnostics.fmt("input.zon")});
1671 }1671 }
16721672
1673 // Enum literals cannot coerce into untagged unions1673 // Enum literals cannot coerce into untagged unions
...@@ -1677,12 +1677,12 @@ test "std.zon unions" {...@@ -1677,12 +1677,12 @@ test "std.zon unions" {
1677 .gpa = gpa,1677 .gpa = gpa,
1678 .arena = arena,1678 .arena = arena,
1679 .source = ".x",1679 .source = ".x",
1680 .errors = &errors,1680 .diagnostics = &diagnostics,
1681 }));1681 }));
1682 try std.testing.expectFmt(1682 try std.testing.expectFmt(
1683 \\input.zon:1:2: error: expected union1683 \\input.zon:1:2: error: expected union
1684 \\1684 \\
1685 , "{f}", .{errors.fmt("input.zon")});1685 , "{f}", .{diagnostics.fmt("input.zon")});
1686 }1686 }
16871687
1688 // Unknown field for enum literal coercion1688 // Unknown field for enum literal coercion
...@@ -1692,13 +1692,13 @@ test "std.zon unions" {...@@ -1692,13 +1692,13 @@ test "std.zon unions" {
1692 .gpa = gpa,1692 .gpa = gpa,
1693 .arena = arena,1693 .arena = arena,
1694 .source = ".y",1694 .source = ".y",
1695 .errors = &errors,1695 .diagnostics = &diagnostics,
1696 }));1696 }));
1697 try std.testing.expectFmt(1697 try std.testing.expectFmt(
1698 \\input.zon:1:2: error: unexpected field 'y'1698 \\input.zon:1:2: error: unexpected field 'y'
1699 \\input.zon:1:2: note: supported: 'x'1699 \\input.zon:1:2: note: supported: 'x'
1700 \\1700 \\
1701 , "{f}", .{errors.fmt("input.zon")});1701 , "{f}", .{diagnostics.fmt("input.zon")});
1702 }1702 }
17031703
1704 // Non void field for enum literal coercion1704 // Non void field for enum literal coercion
...@@ -1708,12 +1708,12 @@ test "std.zon unions" {...@@ -1708,12 +1708,12 @@ test "std.zon unions" {
1708 .gpa = gpa,1708 .gpa = gpa,
1709 .arena = arena,1709 .arena = arena,
1710 .source = ".x",1710 .source = ".x",
1711 .errors = &errors,1711 .diagnostics = &diagnostics,
1712 }));1712 }));
1713 try std.testing.expectFmt(1713 try std.testing.expectFmt(
1714 \\input.zon:1:2: error: expected union1714 \\input.zon:1:2: error: expected union
1715 \\1715 \\
1716 , "{f}", .{errors.fmt("input.zon")});1716 , "{f}", .{diagnostics.fmt("input.zon")});
1717 }1717 }
1718}1718}
17191719
...@@ -1722,7 +1722,7 @@ test "std.zon structs" {...@@ -1722,7 +1722,7 @@ test "std.zon structs" {
1722 var arena_allocator: ArenaAllocator = .init(gpa);1722 var arena_allocator: ArenaAllocator = .init(gpa);
1723 defer arena_allocator.deinit();1723 defer arena_allocator.deinit();
1724 const arena = arena_allocator.allocator();1724 const arena = arena_allocator.allocator();
1725 var errors: Errors = .empty;1725 var diagnostics: Diagnostics = .empty;
17261726
1727 // Structs (various sizes tested since they're parsed differently)1727 // Structs (various sizes tested since they're parsed differently)
1728 {1728 {
...@@ -1735,7 +1735,7 @@ test "std.zon structs" {...@@ -1735,7 +1735,7 @@ test "std.zon structs" {
1735 .gpa = gpa,1735 .gpa = gpa,
1736 .arena = arena,1736 .arena = arena,
1737 .source = ".{}",1737 .source = ".{}",
1738 .errors = &errors,1738 .diagnostics = &diagnostics,
1739 });1739 });
1740 try std.testing.expectEqual(Vec0{}, zero);1740 try std.testing.expectEqual(Vec0{}, zero);
17411741
...@@ -1743,7 +1743,7 @@ test "std.zon structs" {...@@ -1743,7 +1743,7 @@ test "std.zon structs" {
1743 .gpa = gpa,1743 .gpa = gpa,
1744 .arena = arena,1744 .arena = arena,
1745 .source = ".{.x = 1.2}",1745 .source = ".{.x = 1.2}",
1746 .errors = &errors,1746 .diagnostics = &diagnostics,
1747 });1747 });
1748 try std.testing.expectEqual(Vec1{ .x = 1.2 }, one);1748 try std.testing.expectEqual(Vec1{ .x = 1.2 }, one);
17491749
...@@ -1751,7 +1751,7 @@ test "std.zon structs" {...@@ -1751,7 +1751,7 @@ test "std.zon structs" {
1751 .gpa = gpa,1751 .gpa = gpa,
1752 .arena = arena,1752 .arena = arena,
1753 .source = ".{.x = 1.2, .y = 3.4}",1753 .source = ".{.x = 1.2, .y = 3.4}",
1754 .errors = &errors,1754 .diagnostics = &diagnostics,
1755 });1755 });
1756 try std.testing.expectEqual(Vec2{ .x = 1.2, .y = 3.4 }, two);1756 try std.testing.expectEqual(Vec2{ .x = 1.2, .y = 3.4 }, two);
17571757
...@@ -1759,7 +1759,7 @@ test "std.zon structs" {...@@ -1759,7 +1759,7 @@ test "std.zon structs" {
1759 .gpa = gpa,1759 .gpa = gpa,
1760 .arena = arena,1760 .arena = arena,
1761 .source = ".{.x = 1.2, .y = 3.4, .z = 5.6}",1761 .source = ".{.x = 1.2, .y = 3.4, .z = 5.6}",
1762 .errors = &errors,1762 .diagnostics = &diagnostics,
1763 });1763 });
1764 try std.testing.expectEqual(Vec3{ .x = 1.2, .y = 3.4, .z = 5.6 }, three);1764 try std.testing.expectEqual(Vec3{ .x = 1.2, .y = 3.4, .z = 5.6 }, three);
1765 }1765 }
...@@ -1772,7 +1772,7 @@ test "std.zon structs" {...@@ -1772,7 +1772,7 @@ test "std.zon structs" {
1772 .gpa = gpa,1772 .gpa = gpa,
1773 .arena = arena,1773 .arena = arena,
1774 .source = ".{.bar = \"qux\", .baz = .{\"a\", \"b\"}}",1774 .source = ".{.bar = \"qux\", .baz = .{\"a\", \"b\"}}",
1775 .errors = &errors,1775 .diagnostics = &diagnostics,
1776 });1776 });
1777 try std.testing.expectEqualDeep(Foo{ .bar = "qux", .baz = &.{ "a", "b" } }, parsed);1777 try std.testing.expectEqualDeep(Foo{ .bar = "qux", .baz = &.{ "a", "b" } }, parsed);
1778 }1778 }
...@@ -1786,14 +1786,14 @@ test "std.zon structs" {...@@ -1786,14 +1786,14 @@ test "std.zon structs" {
1786 .gpa = gpa,1786 .gpa = gpa,
1787 .arena = arena,1787 .arena = arena,
1788 .source = ".{.x=1.5, .z=2.5}",1788 .source = ".{.x=1.5, .z=2.5}",
1789 .errors = &errors,1789 .diagnostics = &diagnostics,
1790 }),1790 }),
1791 );1791 );
1792 try std.testing.expectFmt(1792 try std.testing.expectFmt(
1793 \\input.zon:1:12: error: unexpected field 'z'1793 \\input.zon:1:12: error: unexpected field 'z'
1794 \\input.zon:1:12: note: supported: 'x', 'y'1794 \\input.zon:1:12: note: supported: 'x', 'y'
1795 \\1795 \\
1796 , "{f}", .{errors.fmt("input.zon")});1796 , "{f}", .{diagnostics.fmt("input.zon")});
1797 }1797 }
17981798
1799 // Duplicate field1799 // Duplicate field
...@@ -1805,14 +1805,14 @@ test "std.zon structs" {...@@ -1805,14 +1805,14 @@ test "std.zon structs" {
1805 .gpa = gpa,1805 .gpa = gpa,
1806 .arena = arena,1806 .arena = arena,
1807 .source = ".{.x=1.5, .x=2.5, .x=3.5}",1807 .source = ".{.x=1.5, .x=2.5, .x=3.5}",
1808 .errors = &errors,1808 .diagnostics = &diagnostics,
1809 }),1809 }),
1810 );1810 );
1811 try std.testing.expectFmt(1811 try std.testing.expectFmt(
1812 \\input.zon:1:4: error: duplicate struct field name1812 \\input.zon:1:4: error: duplicate struct field name
1813 \\input.zon:1:12: note: duplicate name here1813 \\input.zon:1:12: note: duplicate name here
1814 \\1814 \\
1815 , "{f}", .{errors.fmt("input.zon")});1815 , "{f}", .{diagnostics.fmt("input.zon")});
1816 }1816 }
18171817
1818 // Ignore unknown fields1818 // Ignore unknown fields
...@@ -1823,7 +1823,7 @@ test "std.zon structs" {...@@ -1823,7 +1823,7 @@ test "std.zon structs" {
1823 .arena = arena,1823 .arena = arena,
1824 .source = ".{ .x = 1.0, .z = 3.0 }",1824 .source = ".{ .x = 1.0, .z = 3.0 }",
1825 .ignore_unknown_fields = true,1825 .ignore_unknown_fields = true,
1826 .errors = &errors,1826 .diagnostics = &diagnostics,
1827 });1827 });
1828 try std.testing.expectEqual(Vec2{ .x = 1.0, .y = 2.0 }, parsed);1828 try std.testing.expectEqual(Vec2{ .x = 1.0, .y = 2.0 }, parsed);
1829 }1829 }
...@@ -1837,14 +1837,14 @@ test "std.zon structs" {...@@ -1837,14 +1837,14 @@ test "std.zon structs" {
1837 .gpa = gpa,1837 .gpa = gpa,
1838 .arena = arena,1838 .arena = arena,
1839 .source = ".{.x=1.5, .z=2.5}",1839 .source = ".{.x=1.5, .z=2.5}",
1840 .errors = &errors,1840 .diagnostics = &diagnostics,
1841 }),1841 }),
1842 );1842 );
1843 try std.testing.expectFmt(1843 try std.testing.expectFmt(
1844 \\input.zon:1:4: error: unexpected field 'x'1844 \\input.zon:1:4: error: unexpected field 'x'
1845 \\input.zon:1:4: note: none expected1845 \\input.zon:1:4: note: none expected
1846 \\1846 \\
1847 , "{f}", .{errors.fmt("input.zon")});1847 , "{f}", .{diagnostics.fmt("input.zon")});
1848 }1848 }
18491849
1850 // Missing field1850 // Missing field
...@@ -1856,13 +1856,13 @@ test "std.zon structs" {...@@ -1856,13 +1856,13 @@ test "std.zon structs" {
1856 .gpa = gpa,1856 .gpa = gpa,
1857 .arena = arena,1857 .arena = arena,
1858 .source = ".{.x=1.5}",1858 .source = ".{.x=1.5}",
1859 .errors = &errors,1859 .diagnostics = &diagnostics,
1860 }),1860 }),
1861 );1861 );
1862 try std.testing.expectFmt(1862 try std.testing.expectFmt(
1863 \\input.zon:1:2: error: missing required field y1863 \\input.zon:1:2: error: missing required field y
1864 \\1864 \\
1865 , "{f}", .{errors.fmt("input.zon")});1865 , "{f}", .{diagnostics.fmt("input.zon")});
1866 }1866 }
18671867
1868 // Default field1868 // Default field
...@@ -1872,7 +1872,7 @@ test "std.zon structs" {...@@ -1872,7 +1872,7 @@ test "std.zon structs" {
1872 .gpa = gpa,1872 .gpa = gpa,
1873 .arena = arena,1873 .arena = arena,
1874 .source = ".{.x = 1.2}",1874 .source = ".{.x = 1.2}",
1875 .errors = &errors,1875 .diagnostics = &diagnostics,
1876 });1876 });
1877 try std.testing.expectEqual(Vec2{ .x = 1.2, .y = 1.5 }, parsed);1877 try std.testing.expectEqual(Vec2{ .x = 1.2, .y = 1.5 }, parsed);
1878 }1878 }
...@@ -1884,7 +1884,7 @@ test "std.zon structs" {...@@ -1884,7 +1884,7 @@ test "std.zon structs" {
1884 .gpa = gpa,1884 .gpa = gpa,
1885 .arena = arena,1885 .arena = arena,
1886 .source = ".{.x = 1.2}",1886 .source = ".{.x = 1.2}",
1887 .errors = &errors,1887 .diagnostics = &diagnostics,
1888 });1888 });
1889 try std.testing.expectEqual(Vec2{ .x = 1.2, .y = 1.5 }, parsed);1889 try std.testing.expectEqual(Vec2{ .x = 1.2, .y = 1.5 }, parsed);
1890 }1890 }
...@@ -1896,13 +1896,13 @@ test "std.zon structs" {...@@ -1896,13 +1896,13 @@ test "std.zon structs" {
1896 .gpa = gpa,1896 .gpa = gpa,
1897 .arena = arena,1897 .arena = arena,
1898 .source = ".{.x = 1.2, .y = 1.5}",1898 .source = ".{.x = 1.2, .y = 1.5}",
1899 .errors = &errors,1899 .diagnostics = &diagnostics,
1900 });1900 });
1901 try std.testing.expectError(error.ParseZon, parsed);1901 try std.testing.expectError(error.ParseZon, parsed);
1902 try std.testing.expectFmt(1902 try std.testing.expectFmt(
1903 \\input.zon:1:18: error: cannot initialize comptime field1903 \\input.zon:1:18: error: cannot initialize comptime field
1904 \\1904 \\
1905 , "{f}", .{errors.fmt("input.zon")});1905 , "{f}", .{diagnostics.fmt("input.zon")});
1906 }1906 }
19071907
1908 // Enum field (regression test, we were previously getting the field name in an1908 // Enum field (regression test, we were previously getting the field name in an
...@@ -1913,7 +1913,7 @@ test "std.zon structs" {...@@ -1913,7 +1913,7 @@ test "std.zon structs" {
1913 .gpa = gpa,1913 .gpa = gpa,
1914 .arena = arena,1914 .arena = arena,
1915 .source = ".{ .x = .x }",1915 .source = ".{ .x = .x }",
1916 .errors = &errors,1916 .diagnostics = &diagnostics,
1917 });1917 });
1918 try std.testing.expectEqual(Vec0{ .x = .x }, parsed);1918 try std.testing.expectEqual(Vec0{ .x = .x }, parsed);
1919 }1919 }
...@@ -1925,7 +1925,7 @@ test "std.zon structs" {...@@ -1925,7 +1925,7 @@ test "std.zon structs" {
1925 .gpa = gpa,1925 .gpa = gpa,
1926 .arena = arena,1926 .arena = arena,
1927 .source = ".{ .@\"x x\" = .@\"x x\" }",1927 .source = ".{ .@\"x x\" = .@\"x x\" }",
1928 .errors = &errors,1928 .diagnostics = &diagnostics,
1929 });1929 });
1930 try std.testing.expectEqual(Vec0{ .@"x x" = .@"x x" }, parsed);1930 try std.testing.expectEqual(Vec0{ .@"x x" = .@"x x" }, parsed);
1931 }1931 }
...@@ -1938,14 +1938,14 @@ test "std.zon structs" {...@@ -1938,14 +1938,14 @@ test "std.zon structs" {
1938 .gpa = gpa,1938 .gpa = gpa,
1939 .arena = arena,1939 .arena = arena,
1940 .source = "Empty{}",1940 .source = "Empty{}",
1941 .errors = &errors,1941 .diagnostics = &diagnostics,
1942 });1942 });
1943 try std.testing.expectError(error.ParseZon, parsed);1943 try std.testing.expectError(error.ParseZon, parsed);
1944 try std.testing.expectFmt(1944 try std.testing.expectFmt(
1945 \\input.zon:1:1: error: types are not available in ZON1945 \\input.zon:1:1: error: types are not available in ZON
1946 \\input.zon:1:1: note: replace the type with '.'1946 \\input.zon:1:1: note: replace the type with '.'
1947 \\1947 \\
1948 , "{f}", .{errors.fmt("input.zon")});1948 , "{f}", .{diagnostics.fmt("input.zon")});
1949 }1949 }
19501950
1951 // Arrays1951 // Arrays
...@@ -1954,14 +1954,14 @@ test "std.zon structs" {...@@ -1954,14 +1954,14 @@ test "std.zon structs" {
1954 .gpa = gpa,1954 .gpa = gpa,
1955 .arena = arena,1955 .arena = arena,
1956 .source = "[3]u8{1, 2, 3}",1956 .source = "[3]u8{1, 2, 3}",
1957 .errors = &errors,1957 .diagnostics = &diagnostics,
1958 });1958 });
1959 try std.testing.expectError(error.ParseZon, parsed);1959 try std.testing.expectError(error.ParseZon, parsed);
1960 try std.testing.expectFmt(1960 try std.testing.expectFmt(
1961 \\input.zon:1:1: error: types are not available in ZON1961 \\input.zon:1:1: error: types are not available in ZON
1962 \\input.zon:1:1: note: replace the type with '.'1962 \\input.zon:1:1: note: replace the type with '.'
1963 \\1963 \\
1964 , "{f}", .{errors.fmt("input.zon")});1964 , "{f}", .{diagnostics.fmt("input.zon")});
1965 }1965 }
19661966
1967 // Slices1967 // Slices
...@@ -1970,14 +1970,14 @@ test "std.zon structs" {...@@ -1970,14 +1970,14 @@ test "std.zon structs" {
1970 .gpa = gpa,1970 .gpa = gpa,
1971 .arena = arena,1971 .arena = arena,
1972 .source = "[]u8{1, 2, 3}",1972 .source = "[]u8{1, 2, 3}",
1973 .errors = &errors,1973 .diagnostics = &diagnostics,
1974 });1974 });
1975 try std.testing.expectError(error.ParseZon, parsed);1975 try std.testing.expectError(error.ParseZon, parsed);
1976 try std.testing.expectFmt(1976 try std.testing.expectFmt(
1977 \\input.zon:1:1: error: types are not available in ZON1977 \\input.zon:1:1: error: types are not available in ZON
1978 \\input.zon:1:1: note: replace the type with '.'1978 \\input.zon:1:1: note: replace the type with '.'
1979 \\1979 \\
1980 , "{f}", .{errors.fmt("input.zon")});1980 , "{f}", .{diagnostics.fmt("input.zon")});
1981 }1981 }
19821982
1983 // Tuples1983 // Tuples
...@@ -1986,14 +1986,14 @@ test "std.zon structs" {...@@ -1986,14 +1986,14 @@ test "std.zon structs" {
1986 .gpa = gpa,1986 .gpa = gpa,
1987 .arena = arena,1987 .arena = arena,
1988 .source = "Tuple{1, 2, 3}",1988 .source = "Tuple{1, 2, 3}",
1989 .errors = &errors,1989 .diagnostics = &diagnostics,
1990 });1990 });
1991 try std.testing.expectError(error.ParseZon, parsed);1991 try std.testing.expectError(error.ParseZon, parsed);
1992 try std.testing.expectFmt(1992 try std.testing.expectFmt(
1993 \\input.zon:1:1: error: types are not available in ZON1993 \\input.zon:1:1: error: types are not available in ZON
1994 \\input.zon:1:1: note: replace the type with '.'1994 \\input.zon:1:1: note: replace the type with '.'
1995 \\1995 \\
1996 , "{f}", .{errors.fmt("input.zon")});1996 , "{f}", .{diagnostics.fmt("input.zon")});
1997 }1997 }
19981998
1999 // Nested1999 // Nested
...@@ -2002,14 +2002,14 @@ test "std.zon structs" {...@@ -2002,14 +2002,14 @@ test "std.zon structs" {
2002 .gpa = gpa,2002 .gpa = gpa,
2003 .arena = arena,2003 .arena = arena,
2004 .source = ".{ .x = Tuple{1, 2, 3} }",2004 .source = ".{ .x = Tuple{1, 2, 3} }",
2005 .errors = &errors,2005 .diagnostics = &diagnostics,
2006 });2006 });
2007 try std.testing.expectError(error.ParseZon, parsed);2007 try std.testing.expectError(error.ParseZon, parsed);
2008 try std.testing.expectFmt(2008 try std.testing.expectFmt(
2009 \\input.zon:1:9: error: types are not available in ZON2009 \\input.zon:1:9: error: types are not available in ZON
2010 \\input.zon:1:9: note: replace the type with '.'2010 \\input.zon:1:9: note: replace the type with '.'
2011 \\2011 \\
2012 , "{f}", .{errors.fmt("input.zon")});2012 , "{f}", .{diagnostics.fmt("input.zon")});
2013 }2013 }
2014 }2014 }
2015}2015}
...@@ -2019,7 +2019,7 @@ test "std.zon tuples" {...@@ -2019,7 +2019,7 @@ test "std.zon tuples" {
2019 var arena_allocator: ArenaAllocator = .init(gpa);2019 var arena_allocator: ArenaAllocator = .init(gpa);
2020 defer arena_allocator.deinit();2020 defer arena_allocator.deinit();
2021 const arena = arena_allocator.allocator();2021 const arena = arena_allocator.allocator();
2022 var errors: Errors = .empty;2022 var diagnostics: Diagnostics = .empty;
20232023
2024 // Structs (various sizes tested since they're parsed differently)2024 // Structs (various sizes tested since they're parsed differently)
2025 {2025 {
...@@ -2032,7 +2032,7 @@ test "std.zon tuples" {...@@ -2032,7 +2032,7 @@ test "std.zon tuples" {
2032 .gpa = gpa,2032 .gpa = gpa,
2033 .arena = arena,2033 .arena = arena,
2034 .source = ".{}",2034 .source = ".{}",
2035 .errors = &errors,2035 .diagnostics = &diagnostics,
2036 });2036 });
2037 try std.testing.expectEqual(Tuple0{}, zero);2037 try std.testing.expectEqual(Tuple0{}, zero);
20382038
...@@ -2040,7 +2040,7 @@ test "std.zon tuples" {...@@ -2040,7 +2040,7 @@ test "std.zon tuples" {
2040 .gpa = gpa,2040 .gpa = gpa,
2041 .arena = arena,2041 .arena = arena,
2042 .source = ".{1.2}",2042 .source = ".{1.2}",
2043 .errors = &errors,2043 .diagnostics = &diagnostics,
2044 });2044 });
2045 try std.testing.expectEqual(Tuple1{1.2}, one);2045 try std.testing.expectEqual(Tuple1{1.2}, one);
20462046
...@@ -2048,7 +2048,7 @@ test "std.zon tuples" {...@@ -2048,7 +2048,7 @@ test "std.zon tuples" {
2048 .gpa = gpa,2048 .gpa = gpa,
2049 .arena = arena,2049 .arena = arena,
2050 .source = ".{1.2, true}",2050 .source = ".{1.2, true}",
2051 .errors = &errors,2051 .diagnostics = &diagnostics,
2052 });2052 });
2053 try std.testing.expectEqual(Tuple2{ 1.2, true }, two);2053 try std.testing.expectEqual(Tuple2{ 1.2, true }, two);
20542054
...@@ -2056,7 +2056,7 @@ test "std.zon tuples" {...@@ -2056,7 +2056,7 @@ test "std.zon tuples" {
2056 .gpa = gpa,2056 .gpa = gpa,
2057 .arena = arena,2057 .arena = arena,
2058 .source = ".{1.2, false, 3}",2058 .source = ".{1.2, false, 3}",
2059 .errors = &errors,2059 .diagnostics = &diagnostics,
2060 });2060 });
2061 try std.testing.expectEqual(Tuple3{ 1.2, false, 3 }, three);2061 try std.testing.expectEqual(Tuple3{ 1.2, false, 3 }, three);
2062 }2062 }
...@@ -2068,7 +2068,7 @@ test "std.zon tuples" {...@@ -2068,7 +2068,7 @@ test "std.zon tuples" {
2068 .gpa = gpa,2068 .gpa = gpa,
2069 .arena = arena,2069 .arena = arena,
2070 .source = ".{\"hello\", \"world\"}",2070 .source = ".{\"hello\", \"world\"}",
2071 .errors = &errors,2071 .diagnostics = &diagnostics,
2072 });2072 });
2073 try std.testing.expectEqualDeep(Tuple{ "hello", "world" }, parsed);2073 try std.testing.expectEqualDeep(Tuple{ "hello", "world" }, parsed);
2074 }2074 }
...@@ -2082,13 +2082,13 @@ test "std.zon tuples" {...@@ -2082,13 +2082,13 @@ test "std.zon tuples" {
2082 .gpa = gpa,2082 .gpa = gpa,
2083 .arena = arena,2083 .arena = arena,
2084 .source = ".{0.5, true, 123}",2084 .source = ".{0.5, true, 123}",
2085 .errors = &errors,2085 .diagnostics = &diagnostics,
2086 }),2086 }),
2087 );2087 );
2088 try std.testing.expectFmt(2088 try std.testing.expectFmt(
2089 \\input.zon:1:14: error: index 2 outside of tuple length 22089 \\input.zon:1:14: error: index 2 outside of tuple length 2
2090 \\2090 \\
2091 , "{f}", .{errors.fmt("input.zon")});2091 , "{f}", .{diagnostics.fmt("input.zon")});
2092 }2092 }
20932093
2094 // Extra field2094 // Extra field
...@@ -2100,13 +2100,13 @@ test "std.zon tuples" {...@@ -2100,13 +2100,13 @@ test "std.zon tuples" {
2100 .gpa = gpa,2100 .gpa = gpa,
2101 .arena = arena,2101 .arena = arena,
2102 .source = ".{0.5}",2102 .source = ".{0.5}",
2103 .errors = &errors,2103 .diagnostics = &diagnostics,
2104 }),2104 }),
2105 );2105 );
2106 try std.testing.expectFmt(2106 try std.testing.expectFmt(
2107 \\input.zon:1:2: error: missing tuple field with index 12107 \\input.zon:1:2: error: missing tuple field with index 1
2108 \\2108 \\
2109 , "{f}", .{errors.fmt("input.zon")});2109 , "{f}", .{diagnostics.fmt("input.zon")});
2110 }2110 }
21112111
2112 // Tuple with unexpected field names2112 // Tuple with unexpected field names
...@@ -2118,13 +2118,13 @@ test "std.zon tuples" {...@@ -2118,13 +2118,13 @@ test "std.zon tuples" {
2118 .gpa = gpa,2118 .gpa = gpa,
2119 .arena = arena,2119 .arena = arena,
2120 .source = ".{.foo = 10.0}",2120 .source = ".{.foo = 10.0}",
2121 .errors = &errors,2121 .diagnostics = &diagnostics,
2122 }),2122 }),
2123 );2123 );
2124 try std.testing.expectFmt(2124 try std.testing.expectFmt(
2125 \\input.zon:1:2: error: expected tuple2125 \\input.zon:1:2: error: expected tuple
2126 \\2126 \\
2127 , "{f}", .{errors.fmt("input.zon")});2127 , "{f}", .{diagnostics.fmt("input.zon")});
2128 }2128 }
21292129
2130 // Struct with missing field names2130 // Struct with missing field names
...@@ -2136,13 +2136,13 @@ test "std.zon tuples" {...@@ -2136,13 +2136,13 @@ test "std.zon tuples" {
2136 .gpa = gpa,2136 .gpa = gpa,
2137 .arena = arena,2137 .arena = arena,
2138 .source = ".{10.0}",2138 .source = ".{10.0}",
2139 .errors = &errors,2139 .diagnostics = &diagnostics,
2140 }),2140 }),
2141 );2141 );
2142 try std.testing.expectFmt(2142 try std.testing.expectFmt(
2143 \\input.zon:1:2: error: expected struct2143 \\input.zon:1:2: error: expected struct
2144 \\2144 \\
2145 , "{f}", .{errors.fmt("input.zon")});2145 , "{f}", .{diagnostics.fmt("input.zon")});
2146 }2146 }
21472147
2148 // Comptime field2148 // Comptime field
...@@ -2152,7 +2152,7 @@ test "std.zon tuples" {...@@ -2152,7 +2152,7 @@ test "std.zon tuples" {
2152 .gpa = gpa,2152 .gpa = gpa,
2153 .arena = arena,2153 .arena = arena,
2154 .source = ".{ 1.2 }",2154 .source = ".{ 1.2 }",
2155 .errors = &errors,2155 .diagnostics = &diagnostics,
2156 });2156 });
2157 try std.testing.expectEqual(Vec2{ 1.2, 1.5 }, parsed);2157 try std.testing.expectEqual(Vec2{ 1.2, 1.5 }, parsed);
2158 }2158 }
...@@ -2164,13 +2164,13 @@ test "std.zon tuples" {...@@ -2164,13 +2164,13 @@ test "std.zon tuples" {
2164 .gpa = gpa,2164 .gpa = gpa,
2165 .arena = arena,2165 .arena = arena,
2166 .source = ".{ 1.2, 1.5}",2166 .source = ".{ 1.2, 1.5}",
2167 .errors = &errors,2167 .diagnostics = &diagnostics,
2168 });2168 });
2169 try std.testing.expectError(error.ParseZon, parsed);2169 try std.testing.expectError(error.ParseZon, parsed);
2170 try std.testing.expectFmt(2170 try std.testing.expectFmt(
2171 \\input.zon:1:9: error: cannot initialize comptime field2171 \\input.zon:1:9: error: cannot initialize comptime field
2172 \\2172 \\
2173 , "{f}", .{errors.fmt("input.zon")});2173 , "{f}", .{diagnostics.fmt("input.zon")});
2174 }2174 }
2175}2175}
21762176
...@@ -2180,7 +2180,7 @@ test "std.zon arrays and slices" {...@@ -2180,7 +2180,7 @@ test "std.zon arrays and slices" {
2180 var arena_allocator: ArenaAllocator = .init(gpa);2180 var arena_allocator: ArenaAllocator = .init(gpa);
2181 defer arena_allocator.deinit();2181 defer arena_allocator.deinit();
2182 const arena = arena_allocator.allocator();2182 const arena = arena_allocator.allocator();
2183 var errors: Errors = .empty;2183 var diagnostics: Diagnostics = .empty;
21842184
2185 // Literals2185 // Literals
2186 {2186 {
...@@ -2190,7 +2190,7 @@ test "std.zon arrays and slices" {...@@ -2190,7 +2190,7 @@ test "std.zon arrays and slices" {
2190 .gpa = gpa,2190 .gpa = gpa,
2191 .arena = arena,2191 .arena = arena,
2192 .source = ".{}",2192 .source = ".{}",
2193 .errors = &errors,2193 .diagnostics = &diagnostics,
2194 });2194 });
2195 try std.testing.expectEqualSlices(u8, &@as([0]u8, .{}), &zero);2195 try std.testing.expectEqualSlices(u8, &@as([0]u8, .{}), &zero);
21962196
...@@ -2198,7 +2198,7 @@ test "std.zon arrays and slices" {...@@ -2198,7 +2198,7 @@ test "std.zon arrays and slices" {
2198 .gpa = gpa,2198 .gpa = gpa,
2199 .arena = arena,2199 .arena = arena,
2200 .source = ".{'a'}",2200 .source = ".{'a'}",
2201 .errors = &errors,2201 .diagnostics = &diagnostics,
2202 });2202 });
2203 try std.testing.expectEqualSlices(u8, &@as([1]u8, .{'a'}), &one);2203 try std.testing.expectEqualSlices(u8, &@as([1]u8, .{'a'}), &one);
22042204
...@@ -2206,7 +2206,7 @@ test "std.zon arrays and slices" {...@@ -2206,7 +2206,7 @@ test "std.zon arrays and slices" {
2206 .gpa = gpa,2206 .gpa = gpa,
2207 .arena = arena,2207 .arena = arena,
2208 .source = ".{'a', 'b'}",2208 .source = ".{'a', 'b'}",
2209 .errors = &errors,2209 .diagnostics = &diagnostics,
2210 });2210 });
2211 try std.testing.expectEqualSlices(u8, &@as([2]u8, .{ 'a', 'b' }), &two);2211 try std.testing.expectEqualSlices(u8, &@as([2]u8, .{ 'a', 'b' }), &two);
22122212
...@@ -2214,7 +2214,7 @@ test "std.zon arrays and slices" {...@@ -2214,7 +2214,7 @@ test "std.zon arrays and slices" {
2214 .gpa = gpa,2214 .gpa = gpa,
2215 .arena = arena,2215 .arena = arena,
2216 .source = ".{'a', 'b',}",2216 .source = ".{'a', 'b',}",
2217 .errors = &errors,2217 .diagnostics = &diagnostics,
2218 });2218 });
2219 try std.testing.expectEqualSlices(u8, &@as([2]u8, .{ 'a', 'b' }), &two_comma);2219 try std.testing.expectEqualSlices(u8, &@as([2]u8, .{ 'a', 'b' }), &two_comma);
22202220
...@@ -2222,7 +2222,7 @@ test "std.zon arrays and slices" {...@@ -2222,7 +2222,7 @@ test "std.zon arrays and slices" {
2222 .gpa = gpa,2222 .gpa = gpa,
2223 .arena = arena,2223 .arena = arena,
2224 .source = ".{'a', 'b', 'c'}",2224 .source = ".{'a', 'b', 'c'}",
2225 .errors = &errors,2225 .diagnostics = &diagnostics,
2226 });2226 });
2227 try std.testing.expectEqualSlices(u8, &.{ 'a', 'b', 'c' }, &three);2227 try std.testing.expectEqualSlices(u8, &.{ 'a', 'b', 'c' }, &three);
22282228
...@@ -2230,7 +2230,7 @@ test "std.zon arrays and slices" {...@@ -2230,7 +2230,7 @@ test "std.zon arrays and slices" {
2230 .gpa = gpa,2230 .gpa = gpa,
2231 .arena = arena,2231 .arena = arena,
2232 .source = ".{'a', 'b', 'c'}",2232 .source = ".{'a', 'b', 'c'}",
2233 .errors = &errors,2233 .diagnostics = &diagnostics,
2234 });2234 });
2235 const expected_sentinel: [3:'z']u8 = .{ 'a', 'b', 'c' };2235 const expected_sentinel: [3:'z']u8 = .{ 'a', 'b', 'c' };
2236 try std.testing.expectEqualSlices(u8, &expected_sentinel, &sentinel);2236 try std.testing.expectEqualSlices(u8, &expected_sentinel, &sentinel);
...@@ -2242,7 +2242,7 @@ test "std.zon arrays and slices" {...@@ -2242,7 +2242,7 @@ test "std.zon arrays and slices" {
2242 .gpa = gpa,2242 .gpa = gpa,
2243 .arena = arena,2243 .arena = arena,
2244 .source = ".{}",2244 .source = ".{}",
2245 .errors = &errors,2245 .diagnostics = &diagnostics,
2246 });2246 });
2247 try std.testing.expectEqualSlices(u8, @as([]const u8, &.{}), zero);2247 try std.testing.expectEqualSlices(u8, @as([]const u8, &.{}), zero);
22482248
...@@ -2250,7 +2250,7 @@ test "std.zon arrays and slices" {...@@ -2250,7 +2250,7 @@ test "std.zon arrays and slices" {
2250 .gpa = gpa,2250 .gpa = gpa,
2251 .arena = arena,2251 .arena = arena,
2252 .source = ".{'a'}",2252 .source = ".{'a'}",
2253 .errors = &errors,2253 .diagnostics = &diagnostics,
2254 });2254 });
2255 try std.testing.expectEqualSlices(u8, &.{'a'}, one);2255 try std.testing.expectEqualSlices(u8, &.{'a'}, one);
22562256
...@@ -2258,7 +2258,7 @@ test "std.zon arrays and slices" {...@@ -2258,7 +2258,7 @@ test "std.zon arrays and slices" {
2258 .gpa = gpa,2258 .gpa = gpa,
2259 .arena = arena,2259 .arena = arena,
2260 .source = ".{'a', 'b'}",2260 .source = ".{'a', 'b'}",
2261 .errors = &errors,2261 .diagnostics = &diagnostics,
2262 });2262 });
2263 try std.testing.expectEqualSlices(u8, &.{ 'a', 'b' }, two);2263 try std.testing.expectEqualSlices(u8, &.{ 'a', 'b' }, two);
22642264
...@@ -2266,7 +2266,7 @@ test "std.zon arrays and slices" {...@@ -2266,7 +2266,7 @@ test "std.zon arrays and slices" {
2266 .gpa = gpa,2266 .gpa = gpa,
2267 .arena = arena,2267 .arena = arena,
2268 .source = ".{'a', 'b',}",2268 .source = ".{'a', 'b',}",
2269 .errors = &errors,2269 .diagnostics = &diagnostics,
2270 });2270 });
2271 try std.testing.expectEqualSlices(u8, &.{ 'a', 'b' }, two_comma);2271 try std.testing.expectEqualSlices(u8, &.{ 'a', 'b' }, two_comma);
22722272
...@@ -2274,7 +2274,7 @@ test "std.zon arrays and slices" {...@@ -2274,7 +2274,7 @@ test "std.zon arrays and slices" {
2274 .gpa = gpa,2274 .gpa = gpa,
2275 .arena = arena,2275 .arena = arena,
2276 .source = ".{'a', 'b', 'c'}",2276 .source = ".{'a', 'b', 'c'}",
2277 .errors = &errors,2277 .diagnostics = &diagnostics,
2278 });2278 });
2279 try std.testing.expectEqualSlices(u8, &.{ 'a', 'b', 'c' }, three);2279 try std.testing.expectEqualSlices(u8, &.{ 'a', 'b', 'c' }, three);
22802280
...@@ -2282,7 +2282,7 @@ test "std.zon arrays and slices" {...@@ -2282,7 +2282,7 @@ test "std.zon arrays and slices" {
2282 .gpa = gpa,2282 .gpa = gpa,
2283 .arena = arena,2283 .arena = arena,
2284 .source = ".{'a', 'b', 'c'}",2284 .source = ".{'a', 'b', 'c'}",
2285 .errors = &errors,2285 .diagnostics = &diagnostics,
2286 });2286 });
2287 const expected_sentinel: [:'z']const u8 = &.{ 'a', 'b', 'c' };2287 const expected_sentinel: [:'z']const u8 = &.{ 'a', 'b', 'c' };
2288 try std.testing.expectEqualSlices(u8, expected_sentinel, sentinel);2288 try std.testing.expectEqualSlices(u8, expected_sentinel, sentinel);
...@@ -2297,7 +2297,7 @@ test "std.zon arrays and slices" {...@@ -2297,7 +2297,7 @@ test "std.zon arrays and slices" {
2297 .gpa = gpa,2297 .gpa = gpa,
2298 .arena = arena,2298 .arena = arena,
2299 .source = ".{\"abc\"}",2299 .source = ".{\"abc\"}",
2300 .errors = &errors,2300 .diagnostics = &diagnostics,
2301 });2301 });
2302 const expected: [1][]const u8 = .{"abc"};2302 const expected: [1][]const u8 = .{"abc"};
2303 try std.testing.expectEqualDeep(expected, parsed);2303 try std.testing.expectEqualDeep(expected, parsed);
...@@ -2309,7 +2309,7 @@ test "std.zon arrays and slices" {...@@ -2309,7 +2309,7 @@ test "std.zon arrays and slices" {
2309 .gpa = gpa,2309 .gpa = gpa,
2310 .arena = arena,2310 .arena = arena,
2311 .source = ".{\"abc\"}",2311 .source = ".{\"abc\"}",
2312 .errors = &errors,2312 .diagnostics = &diagnostics,
2313 });2313 });
2314 const expected: []const []const u8 = &.{"abc"};2314 const expected: []const []const u8 = &.{"abc"};
2315 try std.testing.expectEqualDeep(expected, parsed);2315 try std.testing.expectEqualDeep(expected, parsed);
...@@ -2324,7 +2324,7 @@ test "std.zon arrays and slices" {...@@ -2324,7 +2324,7 @@ test "std.zon arrays and slices" {
2324 .gpa = gpa,2324 .gpa = gpa,
2325 .arena = arena,2325 .arena = arena,
2326 .source = ".{1}",2326 .source = ".{1}",
2327 .errors = &errors,2327 .diagnostics = &diagnostics,
2328 });2328 });
2329 try std.testing.expectEqual(@as(usize, 1), sentinel.len);2329 try std.testing.expectEqual(@as(usize, 1), sentinel.len);
2330 try std.testing.expectEqual(@as(u8, 1), sentinel[0]);2330 try std.testing.expectEqual(@as(u8, 1), sentinel[0]);
...@@ -2337,7 +2337,7 @@ test "std.zon arrays and slices" {...@@ -2337,7 +2337,7 @@ test "std.zon arrays and slices" {
2337 .gpa = gpa,2337 .gpa = gpa,
2338 .arena = arena,2338 .arena = arena,
2339 .source = ".{1}",2339 .source = ".{1}",
2340 .errors = &errors,2340 .diagnostics = &diagnostics,
2341 });2341 });
2342 try std.testing.expectEqual(@as(usize, 1), sentinel.len);2342 try std.testing.expectEqual(@as(usize, 1), sentinel.len);
2343 try std.testing.expectEqual(@as(u8, 1), sentinel[0]);2343 try std.testing.expectEqual(@as(u8, 1), sentinel[0]);
...@@ -2353,13 +2353,13 @@ test "std.zon arrays and slices" {...@@ -2353,13 +2353,13 @@ test "std.zon arrays and slices" {
2353 .gpa = gpa,2353 .gpa = gpa,
2354 .arena = arena,2354 .arena = arena,
2355 .source = ".{'a', 'b', 'c'}",2355 .source = ".{'a', 'b', 'c'}",
2356 .errors = &errors,2356 .diagnostics = &diagnostics,
2357 }),2357 }),
2358 );2358 );
2359 try std.testing.expectFmt(2359 try std.testing.expectFmt(
2360 \\input.zon:1:3: error: index 0 outside of array of length 02360 \\input.zon:1:3: error: index 0 outside of array of length 0
2361 \\2361 \\
2362 , "{f}", .{errors.fmt("input.zon")});2362 , "{f}", .{diagnostics.fmt("input.zon")});
2363 }2363 }
23642364
2365 // Expect 1 find 22365 // Expect 1 find 2
...@@ -2370,13 +2370,13 @@ test "std.zon arrays and slices" {...@@ -2370,13 +2370,13 @@ test "std.zon arrays and slices" {
2370 .gpa = gpa,2370 .gpa = gpa,
2371 .arena = arena,2371 .arena = arena,
2372 .source = ".{'a', 'b'}",2372 .source = ".{'a', 'b'}",
2373 .errors = &errors,2373 .diagnostics = &diagnostics,
2374 }),2374 }),
2375 );2375 );
2376 try std.testing.expectFmt(2376 try std.testing.expectFmt(
2377 \\input.zon:1:8: error: index 1 outside of array of length 12377 \\input.zon:1:8: error: index 1 outside of array of length 1
2378 \\2378 \\
2379 , "{f}", .{errors.fmt("input.zon")});2379 , "{f}", .{diagnostics.fmt("input.zon")});
2380 }2380 }
23812381
2382 // Expect 2 find 12382 // Expect 2 find 1
...@@ -2387,13 +2387,13 @@ test "std.zon arrays and slices" {...@@ -2387,13 +2387,13 @@ test "std.zon arrays and slices" {
2387 .gpa = gpa,2387 .gpa = gpa,
2388 .arena = arena,2388 .arena = arena,
2389 .source = ".{'a'}",2389 .source = ".{'a'}",
2390 .errors = &errors,2390 .diagnostics = &diagnostics,
2391 }),2391 }),
2392 );2392 );
2393 try std.testing.expectFmt(2393 try std.testing.expectFmt(
2394 \\input.zon:1:2: error: expected 2 array elements; found 12394 \\input.zon:1:2: error: expected 2 array elements; found 1
2395 \\2395 \\
2396 , "{f}", .{errors.fmt("input.zon")});2396 , "{f}", .{diagnostics.fmt("input.zon")});
2397 }2397 }
23982398
2399 // Expect 3 find 02399 // Expect 3 find 0
...@@ -2404,13 +2404,13 @@ test "std.zon arrays and slices" {...@@ -2404,13 +2404,13 @@ test "std.zon arrays and slices" {
2404 .gpa = gpa,2404 .gpa = gpa,
2405 .arena = arena,2405 .arena = arena,
2406 .source = ".{}",2406 .source = ".{}",
2407 .errors = &errors,2407 .diagnostics = &diagnostics,
2408 }),2408 }),
2409 );2409 );
2410 try std.testing.expectFmt(2410 try std.testing.expectFmt(
2411 \\input.zon:1:2: error: expected 3 array elements; found 02411 \\input.zon:1:2: error: expected 3 array elements; found 0
2412 \\2412 \\
2413 , "{f}", .{errors.fmt("input.zon")});2413 , "{f}", .{diagnostics.fmt("input.zon")});
2414 }2414 }
24152415
2416 // Wrong inner type2416 // Wrong inner type
...@@ -2423,13 +2423,13 @@ test "std.zon arrays and slices" {...@@ -2423,13 +2423,13 @@ test "std.zon arrays and slices" {
2423 .gpa = gpa,2423 .gpa = gpa,
2424 .arena = arena,2424 .arena = arena,
2425 .source = ".{'a', 'b', 'c'}",2425 .source = ".{'a', 'b', 'c'}",
2426 .errors = &errors,2426 .diagnostics = &diagnostics,
2427 }),2427 }),
2428 );2428 );
2429 try std.testing.expectFmt(2429 try std.testing.expectFmt(
2430 \\input.zon:1:3: error: expected type 'bool'2430 \\input.zon:1:3: error: expected type 'bool'
2431 \\2431 \\
2432 , "{f}", .{errors.fmt("input.zon")});2432 , "{f}", .{diagnostics.fmt("input.zon")});
2433 }2433 }
24342434
2435 // Slice2435 // Slice
...@@ -2440,13 +2440,13 @@ test "std.zon arrays and slices" {...@@ -2440,13 +2440,13 @@ test "std.zon arrays and slices" {
2440 .gpa = gpa,2440 .gpa = gpa,
2441 .arena = arena,2441 .arena = arena,
2442 .source = ".{'a', 'b', 'c'}",2442 .source = ".{'a', 'b', 'c'}",
2443 .errors = &errors,2443 .diagnostics = &diagnostics,
2444 }),2444 }),
2445 );2445 );
2446 try std.testing.expectFmt(2446 try std.testing.expectFmt(
2447 \\input.zon:1:3: error: expected type 'bool'2447 \\input.zon:1:3: error: expected type 'bool'
2448 \\2448 \\
2449 , "{f}", .{errors.fmt("input.zon")});2449 , "{f}", .{diagnostics.fmt("input.zon")});
2450 }2450 }
2451 }2451 }
24522452
...@@ -2460,25 +2460,25 @@ test "std.zon arrays and slices" {...@@ -2460,25 +2460,25 @@ test "std.zon arrays and slices" {
2460 .gpa = gpa,2460 .gpa = gpa,
2461 .arena = arena,2461 .arena = arena,
2462 .source = "'a'",2462 .source = "'a'",
2463 .errors = &errors,2463 .diagnostics = &diagnostics,
2464 }),2464 }),
2465 );2465 );
2466 try std.testing.expectFmt(2466 try std.testing.expectFmt(
2467 \\input.zon:1:1: error: expected array2467 \\input.zon:1:1: error: expected array
2468 \\2468 \\
2469 , "{f}", .{errors.fmt("input.zon")});2469 , "{f}", .{diagnostics.fmt("input.zon")});
2470 }2470 }
24712471
2472 // Slice2472 // Slice
2473 {2473 {
2474 try std.testing.expectError(2474 try std.testing.expectError(
2475 error.ParseZon,2475 error.ParseZon,
2476 fromSlice([]u8, .{ .gpa = gpa, .arena = arena, .source = "'a'", .errors = &errors }),2476 fromSlice([]u8, .{ .gpa = gpa, .arena = arena, .source = "'a'", .diagnostics = &diagnostics }),
2477 );2477 );
2478 try std.testing.expectFmt(2478 try std.testing.expectFmt(
2479 \\input.zon:1:1: error: expected array2479 \\input.zon:1:1: error: expected array
2480 \\2480 \\
2481 , "{f}", .{errors.fmt("input.zon")});2481 , "{f}", .{diagnostics.fmt("input.zon")});
2482 }2482 }
2483 }2483 }
24842484
...@@ -2486,12 +2486,12 @@ test "std.zon arrays and slices" {...@@ -2486,12 +2486,12 @@ test "std.zon arrays and slices" {
2486 {2486 {
2487 try std.testing.expectError(2487 try std.testing.expectError(
2488 error.ParseZon,2488 error.ParseZon,
2489 fromSlice([]u8, .{ .gpa = gpa, .arena = arena, .source = " &.{'a', 'b', 'c'}", .errors = &errors }),2489 fromSlice([]u8, .{ .gpa = gpa, .arena = arena, .source = " &.{'a', 'b', 'c'}", .diagnostics = &diagnostics }),
2490 );2490 );
2491 try std.testing.expectFmt(2491 try std.testing.expectFmt(
2492 \\input.zon:1:3: error: pointers are not available in ZON2492 \\input.zon:1:3: error: pointers are not available in ZON
2493 \\2493 \\
2494 , "{f}", .{errors.fmt("input.zon")});2494 , "{f}", .{diagnostics.fmt("input.zon")});
2495 }2495 }
2496}2496}
24972497
...@@ -2500,7 +2500,7 @@ test "std.zon string literal" {...@@ -2500,7 +2500,7 @@ test "std.zon string literal" {
2500 var arena_allocator: ArenaAllocator = .init(gpa);2500 var arena_allocator: ArenaAllocator = .init(gpa);
2501 defer arena_allocator.deinit();2501 defer arena_allocator.deinit();
2502 const arena = arena_allocator.allocator();2502 const arena = arena_allocator.allocator();
2503 var errors: Errors = .empty;2503 var diagnostics: Diagnostics = .empty;
25042504
2505 // Basic string literal2505 // Basic string literal
2506 {2506 {
...@@ -2508,7 +2508,7 @@ test "std.zon string literal" {...@@ -2508,7 +2508,7 @@ test "std.zon string literal" {
2508 .gpa = gpa,2508 .gpa = gpa,
2509 .arena = arena,2509 .arena = arena,
2510 .source = "\"abc\"",2510 .source = "\"abc\"",
2511 .errors = &errors,2511 .diagnostics = &diagnostics,
2512 });2512 });
2513 try std.testing.expectEqualStrings(@as([]const u8, "abc"), parsed);2513 try std.testing.expectEqualStrings(@as([]const u8, "abc"), parsed);
2514 }2514 }
...@@ -2519,7 +2519,7 @@ test "std.zon string literal" {...@@ -2519,7 +2519,7 @@ test "std.zon string literal" {
2519 .gpa = gpa,2519 .gpa = gpa,
2520 .arena = arena,2520 .arena = arena,
2521 .source = "\"ab\\nc\"",2521 .source = "\"ab\\nc\"",
2522 .errors = &errors,2522 .diagnostics = &diagnostics,
2523 });2523 });
2524 try std.testing.expectEqualStrings(@as([]const u8, "ab\nc"), parsed);2524 try std.testing.expectEqualStrings(@as([]const u8, "ab\nc"), parsed);
2525 }2525 }
...@@ -2530,7 +2530,7 @@ test "std.zon string literal" {...@@ -2530,7 +2530,7 @@ test "std.zon string literal" {
2530 .gpa = gpa,2530 .gpa = gpa,
2531 .arena = arena,2531 .arena = arena,
2532 .source = "\"ab\\x00c\"",2532 .source = "\"ab\\x00c\"",
2533 .errors = &errors,2533 .diagnostics = &diagnostics,
2534 });2534 });
2535 try std.testing.expectEqualStrings(@as([]const u8, "ab\x00c"), parsed);2535 try std.testing.expectEqualStrings(@as([]const u8, "ab\x00c"), parsed);
2536 }2536 }
...@@ -2540,23 +2540,23 @@ test "std.zon string literal" {...@@ -2540,23 +2540,23 @@ test "std.zon string literal" {
2540 {2540 {
2541 try std.testing.expectError(2541 try std.testing.expectError(
2542 error.ParseZon,2542 error.ParseZon,
2543 fromSlice([]u8, .{ .gpa = gpa, .arena = arena, .source = "\"abcd\"", .errors = &errors }),2543 fromSlice([]u8, .{ .gpa = gpa, .arena = arena, .source = "\"abcd\"", .diagnostics = &diagnostics }),
2544 );2544 );
2545 try std.testing.expectFmt(2545 try std.testing.expectFmt(
2546 \\input.zon:1:1: error: expected array2546 \\input.zon:1:1: error: expected array
2547 \\2547 \\
2548 , "{f}", .{errors.fmt("input.zon")});2548 , "{f}", .{diagnostics.fmt("input.zon")});
2549 }2549 }
25502550
2551 {2551 {
2552 try std.testing.expectError(2552 try std.testing.expectError(
2553 error.ParseZon,2553 error.ParseZon,
2554 fromSlice([]u8, .{ .gpa = gpa, .arena = arena, .source = "\\\\abcd", .errors = &errors }),2554 fromSlice([]u8, .{ .gpa = gpa, .arena = arena, .source = "\\\\abcd", .diagnostics = &diagnostics }),
2555 );2555 );
2556 try std.testing.expectFmt(2556 try std.testing.expectFmt(
2557 \\input.zon:1:1: error: expected array2557 \\input.zon:1:1: error: expected array
2558 \\2558 \\
2559 , "{f}", .{errors.fmt("input.zon")});2559 , "{f}", .{diagnostics.fmt("input.zon")});
2560 }2560 }
2561 }2561 }
25622562
...@@ -2573,13 +2573,13 @@ test "std.zon string literal" {...@@ -2573,13 +2573,13 @@ test "std.zon string literal" {
2573 .gpa = gpa,2573 .gpa = gpa,
2574 .arena = arena,2574 .arena = arena,
2575 .source = "\"abcd\"",2575 .source = "\"abcd\"",
2576 .errors = &errors,2576 .diagnostics = &diagnostics,
2577 }),2577 }),
2578 );2578 );
2579 try std.testing.expectFmt(2579 try std.testing.expectFmt(
2580 \\input.zon:1:1: error: expected array2580 \\input.zon:1:1: error: expected array
2581 \\2581 \\
2582 , "{f}", .{errors.fmt("input.zon")});2582 , "{f}", .{diagnostics.fmt("input.zon")});
2583 }2583 }
25842584
2585 {2585 {
...@@ -2589,13 +2589,13 @@ test "std.zon string literal" {...@@ -2589,13 +2589,13 @@ test "std.zon string literal" {
2589 .gpa = gpa,2589 .gpa = gpa,
2590 .arena = arena,2590 .arena = arena,
2591 .source = "\\\\abcd",2591 .source = "\\\\abcd",
2592 .errors = &errors,2592 .diagnostics = &diagnostics,
2593 }),2593 }),
2594 );2594 );
2595 try std.testing.expectFmt(2595 try std.testing.expectFmt(
2596 \\input.zon:1:1: error: expected array2596 \\input.zon:1:1: error: expected array
2597 \\2597 \\
2598 , "{f}", .{errors.fmt("input.zon")});2598 , "{f}", .{diagnostics.fmt("input.zon")});
2599 }2599 }
2600 }2600 }
26012601
...@@ -2606,7 +2606,7 @@ test "std.zon string literal" {...@@ -2606,7 +2606,7 @@ test "std.zon string literal" {
2606 .gpa = gpa,2606 .gpa = gpa,
2607 .arena = arena,2607 .arena = arena,
2608 .source = "\"abc\"",2608 .source = "\"abc\"",
2609 .errors = &errors,2609 .diagnostics = &diagnostics,
2610 });2610 });
2611 try std.testing.expectEqualStrings("abc", parsed);2611 try std.testing.expectEqualStrings("abc", parsed);
2612 try std.testing.expectEqual(@as(u8, 0), parsed[3]);2612 try std.testing.expectEqual(@as(u8, 0), parsed[3]);
...@@ -2617,7 +2617,7 @@ test "std.zon string literal" {...@@ -2617,7 +2617,7 @@ test "std.zon string literal" {
2617 .gpa = gpa,2617 .gpa = gpa,
2618 .arena = arena,2618 .arena = arena,
2619 .source = "\\\\abc",2619 .source = "\\\\abc",
2620 .errors = &errors,2620 .diagnostics = &diagnostics,
2621 });2621 });
2622 try std.testing.expectEqualStrings("abc", parsed);2622 try std.testing.expectEqualStrings("abc", parsed);
2623 try std.testing.expectEqual(@as(u8, 0), parsed[3]);2623 try std.testing.expectEqual(@as(u8, 0), parsed[3]);
...@@ -2629,23 +2629,23 @@ test "std.zon string literal" {...@@ -2629,23 +2629,23 @@ test "std.zon string literal" {
2629 {2629 {
2630 try std.testing.expectError(2630 try std.testing.expectError(
2631 error.ParseZon,2631 error.ParseZon,
2632 fromSlice([:1]const u8, .{ .gpa = gpa, .arena = arena, .source = "\"foo\"", .errors = &errors }),2632 fromSlice([:1]const u8, .{ .gpa = gpa, .arena = arena, .source = "\"foo\"", .diagnostics = &diagnostics }),
2633 );2633 );
2634 try std.testing.expectFmt(2634 try std.testing.expectFmt(
2635 \\input.zon:1:1: error: expected array2635 \\input.zon:1:1: error: expected array
2636 \\2636 \\
2637 , "{f}", .{errors.fmt("input.zon")});2637 , "{f}", .{diagnostics.fmt("input.zon")});
2638 }2638 }
26392639
2640 {2640 {
2641 try std.testing.expectError(2641 try std.testing.expectError(
2642 error.ParseZon,2642 error.ParseZon,
2643 fromSlice([:1]const u8, .{ .gpa = gpa, .arena = arena, .source = "\\\\foo", .errors = &errors }),2643 fromSlice([:1]const u8, .{ .gpa = gpa, .arena = arena, .source = "\\\\foo", .diagnostics = &diagnostics }),
2644 );2644 );
2645 try std.testing.expectFmt(2645 try std.testing.expectFmt(
2646 \\input.zon:1:1: error: expected array2646 \\input.zon:1:1: error: expected array
2647 \\2647 \\
2648 , "{f}", .{errors.fmt("input.zon")});2648 , "{f}", .{diagnostics.fmt("input.zon")});
2649 }2649 }
2650 }2650 }
26512651
...@@ -2653,36 +2653,36 @@ test "std.zon string literal" {...@@ -2653,36 +2653,36 @@ test "std.zon string literal" {
2653 {2653 {
2654 try std.testing.expectError(2654 try std.testing.expectError(
2655 error.ParseZon,2655 error.ParseZon,
2656 fromSlice([]const u8, .{ .gpa = gpa, .arena = arena, .source = "true", .errors = &errors }),2656 fromSlice([]const u8, .{ .gpa = gpa, .arena = arena, .source = "true", .diagnostics = &diagnostics }),
2657 );2657 );
2658 try std.testing.expectFmt(2658 try std.testing.expectFmt(
2659 \\input.zon:1:1: error: expected string2659 \\input.zon:1:1: error: expected string
2660 \\2660 \\
2661 , "{f}", .{errors.fmt("input.zon")});2661 , "{f}", .{diagnostics.fmt("input.zon")});
2662 }2662 }
26632663
2664 // Expecting string literal, getting an incompatible tuple2664 // Expecting string literal, getting an incompatible tuple
2665 {2665 {
2666 try std.testing.expectError(2666 try std.testing.expectError(
2667 error.ParseZon,2667 error.ParseZon,
2668 fromSlice([]const u8, .{ .gpa = gpa, .arena = arena, .source = ".{false}", .errors = &errors }),2668 fromSlice([]const u8, .{ .gpa = gpa, .arena = arena, .source = ".{false}", .diagnostics = &diagnostics }),
2669 );2669 );
2670 try std.testing.expectFmt(2670 try std.testing.expectFmt(
2671 \\input.zon:1:3: error: expected type 'u8'2671 \\input.zon:1:3: error: expected type 'u8'
2672 \\2672 \\
2673 , "{f}", .{errors.fmt("input.zon")});2673 , "{f}", .{diagnostics.fmt("input.zon")});
2674 }2674 }
26752675
2676 // Invalid string literal2676 // Invalid string literal
2677 {2677 {
2678 try std.testing.expectError(2678 try std.testing.expectError(
2679 error.ParseZon,2679 error.ParseZon,
2680 fromSlice([]const i8, .{ .gpa = gpa, .arena = arena, .source = "\"\\a\"", .errors = &errors }),2680 fromSlice([]const i8, .{ .gpa = gpa, .arena = arena, .source = "\"\\a\"", .diagnostics = &diagnostics }),
2681 );2681 );
2682 try std.testing.expectFmt(2682 try std.testing.expectFmt(
2683 \\input.zon:1:3: error: invalid escape character: 'a'2683 \\input.zon:1:3: error: invalid escape character: 'a'
2684 \\2684 \\
2685 , "{f}", .{errors.fmt("input.zon")});2685 , "{f}", .{diagnostics.fmt("input.zon")});
2686 }2686 }
26872687
2688 // Slice wrong child type2688 // Slice wrong child type
...@@ -2690,23 +2690,23 @@ test "std.zon string literal" {...@@ -2690,23 +2690,23 @@ test "std.zon string literal" {
2690 {2690 {
2691 try std.testing.expectError(2691 try std.testing.expectError(
2692 error.ParseZon,2692 error.ParseZon,
2693 fromSlice([]const i8, .{ .gpa = gpa, .arena = arena, .source = "\"a\"", .errors = &errors }),2693 fromSlice([]const i8, .{ .gpa = gpa, .arena = arena, .source = "\"a\"", .diagnostics = &diagnostics }),
2694 );2694 );
2695 try std.testing.expectFmt(2695 try std.testing.expectFmt(
2696 \\input.zon:1:1: error: expected array2696 \\input.zon:1:1: error: expected array
2697 \\2697 \\
2698 , "{f}", .{errors.fmt("input.zon")});2698 , "{f}", .{diagnostics.fmt("input.zon")});
2699 }2699 }
27002700
2701 {2701 {
2702 try std.testing.expectError(2702 try std.testing.expectError(
2703 error.ParseZon,2703 error.ParseZon,
2704 fromSlice([]const i8, .{ .gpa = gpa, .arena = arena, .source = "\\\\a", .errors = &errors }),2704 fromSlice([]const i8, .{ .gpa = gpa, .arena = arena, .source = "\\\\a", .diagnostics = &diagnostics }),
2705 );2705 );
2706 try std.testing.expectFmt(2706 try std.testing.expectFmt(
2707 \\input.zon:1:1: error: expected array2707 \\input.zon:1:1: error: expected array
2708 \\2708 \\
2709 , "{f}", .{errors.fmt("input.zon")});2709 , "{f}", .{diagnostics.fmt("input.zon")});
2710 }2710 }
2711 }2711 }
27122712
...@@ -2719,13 +2719,13 @@ test "std.zon string literal" {...@@ -2719,13 +2719,13 @@ test "std.zon string literal" {
2719 .gpa = gpa,2719 .gpa = gpa,
2720 .arena = arena,2720 .arena = arena,
2721 .source = "\"abc\"",2721 .source = "\"abc\"",
2722 .errors = &errors,2722 .diagnostics = &diagnostics,
2723 }),2723 }),
2724 );2724 );
2725 try std.testing.expectFmt(2725 try std.testing.expectFmt(
2726 \\input.zon:1:1: error: expected array2726 \\input.zon:1:1: error: expected array
2727 \\2727 \\
2728 , "{f}", .{errors.fmt("input.zon")});2728 , "{f}", .{diagnostics.fmt("input.zon")});
2729 }2729 }
27302730
2731 {2731 {
...@@ -2735,13 +2735,13 @@ test "std.zon string literal" {...@@ -2735,13 +2735,13 @@ test "std.zon string literal" {
2735 .gpa = gpa,2735 .gpa = gpa,
2736 .arena = arena,2736 .arena = arena,
2737 .source = "\\\\abc",2737 .source = "\\\\abc",
2738 .errors = &errors,2738 .diagnostics = &diagnostics,
2739 }),2739 }),
2740 );2740 );
2741 try std.testing.expectFmt(2741 try std.testing.expectFmt(
2742 \\input.zon:1:1: error: expected array2742 \\input.zon:1:1: error: expected array
2743 \\2743 \\
2744 , "{f}", .{errors.fmt("input.zon")});2744 , "{f}", .{diagnostics.fmt("input.zon")});
2745 }2745 }
2746 }2746 }
27472747
...@@ -2775,7 +2775,7 @@ test "std.zon string literal" {...@@ -2775,7 +2775,7 @@ test "std.zon string literal" {
2775 \\ \\and this.2775 \\ \\and this.
2776 \\}2776 \\}
2777 ,2777 ,
2778 .errors = &errors,2778 .diagnostics = &diagnostics,
2779 });2779 });
2780 try std.testing.expectEqualStrings(2780 try std.testing.expectEqualStrings(
2781 "hello, world!\nthis is a multiline string!\n\n...",2781 "hello, world!\nthis is a multiline string!\n\n...",
...@@ -2792,7 +2792,7 @@ test "std.zon enum literals" {...@@ -2792,7 +2792,7 @@ test "std.zon enum literals" {
2792 var arena_allocator: ArenaAllocator = .init(gpa);2792 var arena_allocator: ArenaAllocator = .init(gpa);
2793 defer arena_allocator.deinit();2793 defer arena_allocator.deinit();
2794 const arena = arena_allocator.allocator();2794 const arena = arena_allocator.allocator();
2795 var errors: Errors = .empty;2795 var diagnostics: Diagnostics = .empty;
27962796
2797 const Enum = enum {2797 const Enum = enum {
2798 foo,2798 foo,
...@@ -2806,19 +2806,19 @@ test "std.zon enum literals" {...@@ -2806,19 +2806,19 @@ test "std.zon enum literals" {
2806 .gpa = gpa,2806 .gpa = gpa,
2807 .arena = arena,2807 .arena = arena,
2808 .source = ".foo",2808 .source = ".foo",
2809 .errors = &errors,2809 .diagnostics = &diagnostics,
2810 }));2810 }));
2811 try std.testing.expectEqual(Enum.bar, try fromSliceNoAlloc(Enum, .{2811 try std.testing.expectEqual(Enum.bar, try fromSliceNoAlloc(Enum, .{
2812 .gpa = gpa,2812 .gpa = gpa,
2813 .arena = arena,2813 .arena = arena,
2814 .source = ".bar",2814 .source = ".bar",
2815 .errors = &errors,2815 .diagnostics = &diagnostics,
2816 }));2816 }));
2817 try std.testing.expectEqual(Enum.baz, try fromSliceNoAlloc(Enum, .{2817 try std.testing.expectEqual(Enum.baz, try fromSliceNoAlloc(Enum, .{
2818 .gpa = gpa,2818 .gpa = gpa,
2819 .arena = arena,2819 .arena = arena,
2820 .source = ".baz",2820 .source = ".baz",
2821 .errors = &errors,2821 .diagnostics = &diagnostics,
2822 }));2822 }));
2823 try std.testing.expectEqual(2823 try std.testing.expectEqual(
2824 Enum.@"ab\nc",2824 Enum.@"ab\nc",
...@@ -2826,7 +2826,7 @@ test "std.zon enum literals" {...@@ -2826,7 +2826,7 @@ test "std.zon enum literals" {
2826 .gpa = gpa,2826 .gpa = gpa,
2827 .arena = arena,2827 .arena = arena,
2828 .source = ".@\"ab\\nc\"",2828 .source = ".@\"ab\\nc\"",
2829 .errors = &errors,2829 .diagnostics = &diagnostics,
2830 }),2830 }),
2831 );2831 );
28322832
...@@ -2838,14 +2838,14 @@ test "std.zon enum literals" {...@@ -2838,14 +2838,14 @@ test "std.zon enum literals" {
2838 .gpa = gpa,2838 .gpa = gpa,
2839 .arena = arena,2839 .arena = arena,
2840 .source = ".qux",2840 .source = ".qux",
2841 .errors = &errors,2841 .diagnostics = &diagnostics,
2842 }),2842 }),
2843 );2843 );
2844 try std.testing.expectFmt(2844 try std.testing.expectFmt(
2845 \\input.zon:1:2: error: unexpected enum literal 'qux'2845 \\input.zon:1:2: error: unexpected enum literal 'qux'
2846 \\input.zon:1:2: note: supported: 'foo', 'bar', 'baz', '@"ab\nc"'2846 \\input.zon:1:2: note: supported: 'foo', 'bar', 'baz', '@"ab\nc"'
2847 \\2847 \\
2848 , "{f}", .{errors.fmt("input.zon")});2848 , "{f}", .{diagnostics.fmt("input.zon")});
2849 }2849 }
28502850
2851 // Bad tag that's too long for parser2851 // Bad tag that's too long for parser
...@@ -2856,14 +2856,14 @@ test "std.zon enum literals" {...@@ -2856,14 +2856,14 @@ test "std.zon enum literals" {
2856 .gpa = gpa,2856 .gpa = gpa,
2857 .arena = arena,2857 .arena = arena,
2858 .source = ".@\"foobarbaz\"",2858 .source = ".@\"foobarbaz\"",
2859 .errors = &errors,2859 .diagnostics = &diagnostics,
2860 }),2860 }),
2861 );2861 );
2862 try std.testing.expectFmt(2862 try std.testing.expectFmt(
2863 \\input.zon:1:2: error: unexpected enum literal 'foobarbaz'2863 \\input.zon:1:2: error: unexpected enum literal 'foobarbaz'
2864 \\input.zon:1:2: note: supported: 'foo', 'bar', 'baz', '@"ab\nc"'2864 \\input.zon:1:2: note: supported: 'foo', 'bar', 'baz', '@"ab\nc"'
2865 \\2865 \\
2866 , "{f}", .{errors.fmt("input.zon")});2866 , "{f}", .{diagnostics.fmt("input.zon")});
2867 }2867 }
28682868
2869 // Bad type2869 // Bad type
...@@ -2874,13 +2874,13 @@ test "std.zon enum literals" {...@@ -2874,13 +2874,13 @@ test "std.zon enum literals" {
2874 .gpa = gpa,2874 .gpa = gpa,
2875 .arena = arena,2875 .arena = arena,
2876 .source = "true",2876 .source = "true",
2877 .errors = &errors,2877 .diagnostics = &diagnostics,
2878 }),2878 }),
2879 );2879 );
2880 try std.testing.expectFmt(2880 try std.testing.expectFmt(
2881 \\input.zon:1:1: error: expected enum literal2881 \\input.zon:1:1: error: expected enum literal
2882 \\2882 \\
2883 , "{f}", .{errors.fmt("input.zon")});2883 , "{f}", .{diagnostics.fmt("input.zon")});
2884 }2884 }
28852885
2886 // Test embedded nulls in an identifier2886 // Test embedded nulls in an identifier
...@@ -2891,13 +2891,13 @@ test "std.zon enum literals" {...@@ -2891,13 +2891,13 @@ test "std.zon enum literals" {
2891 .gpa = gpa,2891 .gpa = gpa,
2892 .arena = arena,2892 .arena = arena,
2893 .source = ".@\"\\x00\"",2893 .source = ".@\"\\x00\"",
2894 .errors = &errors,2894 .diagnostics = &diagnostics,
2895 }),2895 }),
2896 );2896 );
2897 try std.testing.expectFmt(2897 try std.testing.expectFmt(
2898 \\input.zon:1:2: error: identifier cannot contain null bytes2898 \\input.zon:1:2: error: identifier cannot contain null bytes
2899 \\2899 \\
2900 , "{f}", .{errors.fmt("input.zon")});2900 , "{f}", .{diagnostics.fmt("input.zon")});
2901 }2901 }
2902}2902}
29032903
...@@ -2906,20 +2906,20 @@ test "std.zon parse bool" {...@@ -2906,20 +2906,20 @@ test "std.zon parse bool" {
2906 var arena_allocator: ArenaAllocator = .init(gpa);2906 var arena_allocator: ArenaAllocator = .init(gpa);
2907 defer arena_allocator.deinit();2907 defer arena_allocator.deinit();
2908 const arena = arena_allocator.allocator();2908 const arena = arena_allocator.allocator();
2909 var errors: Errors = .empty;2909 var diagnostics: Diagnostics = .empty;
29102910
2911 // Correct bools2911 // Correct bools
2912 try std.testing.expectEqual(true, try fromSliceNoAlloc(bool, .{2912 try std.testing.expectEqual(true, try fromSliceNoAlloc(bool, .{
2913 .gpa = gpa,2913 .gpa = gpa,
2914 .arena = arena,2914 .arena = arena,
2915 .source = "true",2915 .source = "true",
2916 .errors = &errors,2916 .diagnostics = &diagnostics,
2917 }));2917 }));
2918 try std.testing.expectEqual(false, try fromSliceNoAlloc(bool, .{2918 try std.testing.expectEqual(false, try fromSliceNoAlloc(bool, .{
2919 .gpa = gpa,2919 .gpa = gpa,
2920 .arena = arena,2920 .arena = arena,
2921 .source = "false",2921 .source = "false",
2922 .errors = &errors,2922 .diagnostics = &diagnostics,
2923 }));2923 }));
29242924
2925 // Errors2925 // Errors
...@@ -2930,7 +2930,7 @@ test "std.zon parse bool" {...@@ -2930,7 +2930,7 @@ test "std.zon parse bool" {
2930 .gpa = gpa,2930 .gpa = gpa,
2931 .arena = arena,2931 .arena = arena,
2932 .source = " foo",2932 .source = " foo",
2933 .errors = &errors,2933 .diagnostics = &diagnostics,
2934 }),2934 }),
2935 );2935 );
2936 try std.testing.expectFmt(2936 try std.testing.expectFmt(
...@@ -2938,19 +2938,19 @@ test "std.zon parse bool" {...@@ -2938,19 +2938,19 @@ test "std.zon parse bool" {
2938 \\input.zon:1:2: note: ZON allows identifiers 'true', 'false', 'null', 'inf', and 'nan'2938 \\input.zon:1:2: note: ZON allows identifiers 'true', 'false', 'null', 'inf', and 'nan'
2939 \\input.zon:1:2: note: precede identifier with '.' for an enum literal2939 \\input.zon:1:2: note: precede identifier with '.' for an enum literal
2940 \\2940 \\
2941 , "{f}", .{errors.fmt("input.zon")});2941 , "{f}", .{diagnostics.fmt("input.zon")});
2942 }2942 }
2943 {2943 {
2944 try std.testing.expectError(error.ParseZon, fromSliceNoAlloc(bool, .{2944 try std.testing.expectError(error.ParseZon, fromSliceNoAlloc(bool, .{
2945 .gpa = gpa,2945 .gpa = gpa,
2946 .arena = arena,2946 .arena = arena,
2947 .source = "123",2947 .source = "123",
2948 .errors = &errors,2948 .diagnostics = &diagnostics,
2949 }));2949 }));
2950 try std.testing.expectFmt(2950 try std.testing.expectFmt(
2951 \\input.zon:1:1: error: expected type 'bool'2951 \\input.zon:1:1: error: expected type 'bool'
2952 \\2952 \\
2953 , "{f}", .{errors.fmt("input.zon")});2953 , "{f}", .{diagnostics.fmt("input.zon")});
2954 }2954 }
2955}2955}
29562956
...@@ -2981,32 +2981,32 @@ test "std.zon parse int" {...@@ -2981,32 +2981,32 @@ test "std.zon parse int" {
2981 var arena_allocator: ArenaAllocator = .init(gpa);2981 var arena_allocator: ArenaAllocator = .init(gpa);
2982 defer arena_allocator.deinit();2982 defer arena_allocator.deinit();
2983 const arena = arena_allocator.allocator();2983 const arena = arena_allocator.allocator();
2984 var errors: Errors = .empty;2984 var diagnostics: Diagnostics = .empty;
29852985
2986 // Test various numbers and types2986 // Test various numbers and types
2987 try std.testing.expectEqual(@as(u8, 10), try fromSliceNoAlloc(u8, .{2987 try std.testing.expectEqual(@as(u8, 10), try fromSliceNoAlloc(u8, .{
2988 .gpa = gpa,2988 .gpa = gpa,
2989 .arena = arena,2989 .arena = arena,
2990 .source = "10",2990 .source = "10",
2991 .errors = &errors,2991 .diagnostics = &diagnostics,
2992 }));2992 }));
2993 try std.testing.expectEqual(@as(i16, 24), try fromSliceNoAlloc(i16, .{2993 try std.testing.expectEqual(@as(i16, 24), try fromSliceNoAlloc(i16, .{
2994 .gpa = gpa,2994 .gpa = gpa,
2995 .arena = arena,2995 .arena = arena,
2996 .source = "24",2996 .source = "24",
2997 .errors = &errors,2997 .diagnostics = &diagnostics,
2998 }));2998 }));
2999 try std.testing.expectEqual(@as(i14, -4), try fromSliceNoAlloc(i14, .{2999 try std.testing.expectEqual(@as(i14, -4), try fromSliceNoAlloc(i14, .{
3000 .gpa = gpa,3000 .gpa = gpa,
3001 .arena = arena,3001 .arena = arena,
3002 .source = "-4",3002 .source = "-4",
3003 .errors = &errors,3003 .diagnostics = &diagnostics,
3004 }));3004 }));
3005 try std.testing.expectEqual(@as(i32, -123), try fromSliceNoAlloc(i32, .{3005 try std.testing.expectEqual(@as(i32, -123), try fromSliceNoAlloc(i32, .{
3006 .gpa = gpa,3006 .gpa = gpa,
3007 .arena = arena,3007 .arena = arena,
3008 .source = "-123",3008 .source = "-123",
3009 .errors = &errors,3009 .diagnostics = &diagnostics,
3010 }));3010 }));
30113011
3012 // Test limits3012 // Test limits
...@@ -3014,13 +3014,13 @@ test "std.zon parse int" {...@@ -3014,13 +3014,13 @@ test "std.zon parse int" {
3014 .gpa = gpa,3014 .gpa = gpa,
3015 .arena = arena,3015 .arena = arena,
3016 .source = "127",3016 .source = "127",
3017 .errors = &errors,3017 .diagnostics = &diagnostics,
3018 }));3018 }));
3019 try std.testing.expectEqual(@as(i8, -128), try fromSliceNoAlloc(i8, .{3019 try std.testing.expectEqual(@as(i8, -128), try fromSliceNoAlloc(i8, .{
3020 .gpa = gpa,3020 .gpa = gpa,
3021 .arena = arena,3021 .arena = arena,
3022 .source = "-128",3022 .source = "-128",
3023 .errors = &errors,3023 .diagnostics = &diagnostics,
3024 }));3024 }));
30253025
3026 // Test characters3026 // Test characters
...@@ -3028,13 +3028,13 @@ test "std.zon parse int" {...@@ -3028,13 +3028,13 @@ test "std.zon parse int" {
3028 .gpa = gpa,3028 .gpa = gpa,
3029 .arena = arena,3029 .arena = arena,
3030 .source = "'a'",3030 .source = "'a'",
3031 .errors = &errors,3031 .diagnostics = &diagnostics,
3032 }));3032 }));
3033 try std.testing.expectEqual(@as(u8, 'z'), try fromSliceNoAlloc(u8, .{3033 try std.testing.expectEqual(@as(u8, 'z'), try fromSliceNoAlloc(u8, .{
3034 .gpa = gpa,3034 .gpa = gpa,
3035 .arena = arena,3035 .arena = arena,
3036 .source = "'z'",3036 .source = "'z'",
3037 .errors = &errors,3037 .diagnostics = &diagnostics,
3038 }));3038 }));
30393039
3040 // Test big integers3040 // Test big integers
...@@ -3044,7 +3044,7 @@ test "std.zon parse int" {...@@ -3044,7 +3044,7 @@ test "std.zon parse int" {
3044 .gpa = gpa,3044 .gpa = gpa,
3045 .arena = arena,3045 .arena = arena,
3046 .source = "36893488147419103231",3046 .source = "36893488147419103231",
3047 .errors = &errors,3047 .diagnostics = &diagnostics,
3048 }),3048 }),
3049 );3049 );
3050 try std.testing.expectEqual(3050 try std.testing.expectEqual(
...@@ -3053,7 +3053,7 @@ test "std.zon parse int" {...@@ -3053,7 +3053,7 @@ test "std.zon parse int" {
3053 .gpa = gpa,3053 .gpa = gpa,
3054 .arena = arena,3054 .arena = arena,
3055 .source = "368934_881_474191032_31",3055 .source = "368934_881_474191032_31",
3056 .errors = &errors,3056 .diagnostics = &diagnostics,
3057 }),3057 }),
3058 );3058 );
3059 try std.testing.expectEqual(3059 try std.testing.expectEqual(
...@@ -3062,7 +3062,7 @@ test "std.zon parse int" {...@@ -3062,7 +3062,7 @@ test "std.zon parse int" {
3062 .gpa = gpa,3062 .gpa = gpa,
3063 .arena = arena,3063 .arena = arena,
3064 .source = "340282366920938463463374607431768211455",3064 .source = "340282366920938463463374607431768211455",
3065 .errors = &errors,3065 .diagnostics = &diagnostics,
3066 }),3066 }),
3067 );3067 );
30683068
...@@ -3073,7 +3073,7 @@ test "std.zon parse int" {...@@ -3073,7 +3073,7 @@ test "std.zon parse int" {
3073 .gpa = gpa,3073 .gpa = gpa,
3074 .arena = arena,3074 .arena = arena,
3075 .source = "36893488147419103231",3075 .source = "36893488147419103231",
3076 .errors = &errors,3076 .diagnostics = &diagnostics,
3077 }),3077 }),
3078 );3078 );
3079 try std.testing.expectEqual(3079 try std.testing.expectEqual(
...@@ -3082,7 +3082,7 @@ test "std.zon parse int" {...@@ -3082,7 +3082,7 @@ test "std.zon parse int" {
3082 .gpa = gpa,3082 .gpa = gpa,
3083 .arena = arena,3083 .arena = arena,
3084 .source = "-36893488147419103232",3084 .source = "-36893488147419103232",
3085 .errors = &errors,3085 .diagnostics = &diagnostics,
3086 }),3086 }),
3087 );3087 );
3088 {3088 {
...@@ -3090,24 +3090,24 @@ test "std.zon parse int" {...@@ -3090,24 +3090,24 @@ test "std.zon parse int" {
3090 .gpa = gpa,3090 .gpa = gpa,
3091 .arena = arena,3091 .arena = arena,
3092 .source = "36893488147419103232",3092 .source = "36893488147419103232",
3093 .errors = &errors,3093 .diagnostics = &diagnostics,
3094 }));3094 }));
3095 try std.testing.expectFmt(3095 try std.testing.expectFmt(
3096 \\input.zon:1:1: error: type 'i66' cannot represent value3096 \\input.zon:1:1: error: type 'i66' cannot represent value
3097 \\3097 \\
3098 , "{f}", .{errors.fmt("input.zon")});3098 , "{f}", .{diagnostics.fmt("input.zon")});
3099 }3099 }
3100 {3100 {
3101 try std.testing.expectError(error.ParseZon, fromSliceNoAlloc(i66, .{3101 try std.testing.expectError(error.ParseZon, fromSliceNoAlloc(i66, .{
3102 .gpa = gpa,3102 .gpa = gpa,
3103 .arena = arena,3103 .arena = arena,
3104 .source = "-36893488147419103233",3104 .source = "-36893488147419103233",
3105 .errors = &errors,3105 .diagnostics = &diagnostics,
3106 }));3106 }));
3107 try std.testing.expectFmt(3107 try std.testing.expectFmt(
3108 \\input.zon:1:1: error: type 'i66' cannot represent value3108 \\input.zon:1:1: error: type 'i66' cannot represent value
3109 \\3109 \\
3110 , "{f}", .{errors.fmt("input.zon")});3110 , "{f}", .{diagnostics.fmt("input.zon")});
3111 }3111 }
31123112
3113 // Test parsing whole number floats as integers3113 // Test parsing whole number floats as integers
...@@ -3115,13 +3115,13 @@ test "std.zon parse int" {...@@ -3115,13 +3115,13 @@ test "std.zon parse int" {
3115 .gpa = gpa,3115 .gpa = gpa,
3116 .arena = arena,3116 .arena = arena,
3117 .source = "-1.0",3117 .source = "-1.0",
3118 .errors = &errors,3118 .diagnostics = &diagnostics,
3119 }));3119 }));
3120 try std.testing.expectEqual(@as(i8, 123), try fromSliceNoAlloc(i8, .{3120 try std.testing.expectEqual(@as(i8, 123), try fromSliceNoAlloc(i8, .{
3121 .gpa = gpa,3121 .gpa = gpa,
3122 .arena = arena,3122 .arena = arena,
3123 .source = "123.0",3123 .source = "123.0",
3124 .errors = &errors,3124 .diagnostics = &diagnostics,
3125 }));3125 }));
31263126
3127 // Test non-decimal integers3127 // Test non-decimal integers
...@@ -3129,37 +3129,37 @@ test "std.zon parse int" {...@@ -3129,37 +3129,37 @@ test "std.zon parse int" {
3129 .gpa = gpa,3129 .gpa = gpa,
3130 .arena = arena,3130 .arena = arena,
3131 .source = "0xff",3131 .source = "0xff",
3132 .errors = &errors,3132 .diagnostics = &diagnostics,
3133 }));3133 }));
3134 try std.testing.expectEqual(@as(i16, -0xff), try fromSliceNoAlloc(i16, .{3134 try std.testing.expectEqual(@as(i16, -0xff), try fromSliceNoAlloc(i16, .{
3135 .gpa = gpa,3135 .gpa = gpa,
3136 .arena = arena,3136 .arena = arena,
3137 .source = "-0xff",3137 .source = "-0xff",
3138 .errors = &errors,3138 .diagnostics = &diagnostics,
3139 }));3139 }));
3140 try std.testing.expectEqual(@as(i16, 0o77), try fromSliceNoAlloc(i16, .{3140 try std.testing.expectEqual(@as(i16, 0o77), try fromSliceNoAlloc(i16, .{
3141 .gpa = gpa,3141 .gpa = gpa,
3142 .arena = arena,3142 .arena = arena,
3143 .source = "0o77",3143 .source = "0o77",
3144 .errors = &errors,3144 .diagnostics = &diagnostics,
3145 }));3145 }));
3146 try std.testing.expectEqual(@as(i16, -0o77), try fromSliceNoAlloc(i16, .{3146 try std.testing.expectEqual(@as(i16, -0o77), try fromSliceNoAlloc(i16, .{
3147 .gpa = gpa,3147 .gpa = gpa,
3148 .arena = arena,3148 .arena = arena,
3149 .source = "-0o77",3149 .source = "-0o77",
3150 .errors = &errors,3150 .diagnostics = &diagnostics,
3151 }));3151 }));
3152 try std.testing.expectEqual(@as(i16, 0b11), try fromSliceNoAlloc(i16, .{3152 try std.testing.expectEqual(@as(i16, 0b11), try fromSliceNoAlloc(i16, .{
3153 .gpa = gpa,3153 .gpa = gpa,
3154 .arena = arena,3154 .arena = arena,
3155 .source = "0b11",3155 .source = "0b11",
3156 .errors = &errors,3156 .diagnostics = &diagnostics,
3157 }));3157 }));
3158 try std.testing.expectEqual(@as(i16, -0b11), try fromSliceNoAlloc(i16, .{3158 try std.testing.expectEqual(@as(i16, -0b11), try fromSliceNoAlloc(i16, .{
3159 .gpa = gpa,3159 .gpa = gpa,
3160 .arena = arena,3160 .arena = arena,
3161 .source = "-0b11",3161 .source = "-0b11",
3162 .errors = &errors,3162 .diagnostics = &diagnostics,
3163 }));3163 }));
31643164
3165 // Test non-decimal big integers3165 // Test non-decimal big integers
...@@ -3167,55 +3167,55 @@ test "std.zon parse int" {...@@ -3167,55 +3167,55 @@ test "std.zon parse int" {
3167 .gpa = gpa,3167 .gpa = gpa,
3168 .arena = arena,3168 .arena = arena,
3169 .source = "0x1ffffffffffffffff",3169 .source = "0x1ffffffffffffffff",
3170 .errors = &errors,3170 .diagnostics = &diagnostics,
3171 }));3171 }));
3172 try std.testing.expectEqual(@as(i66, 0x1ffffffffffffffff), try fromSliceNoAlloc(i66, .{3172 try std.testing.expectEqual(@as(i66, 0x1ffffffffffffffff), try fromSliceNoAlloc(i66, .{
3173 .gpa = gpa,3173 .gpa = gpa,
3174 .arena = arena,3174 .arena = arena,
3175 .source = "0x1ffffffffffffffff",3175 .source = "0x1ffffffffffffffff",
3176 .errors = &errors,3176 .diagnostics = &diagnostics,
3177 }));3177 }));
3178 try std.testing.expectEqual(@as(i66, -0x1ffffffffffffffff), try fromSliceNoAlloc(i66, .{3178 try std.testing.expectEqual(@as(i66, -0x1ffffffffffffffff), try fromSliceNoAlloc(i66, .{
3179 .gpa = gpa,3179 .gpa = gpa,
3180 .arena = arena,3180 .arena = arena,
3181 .source = "-0x1ffffffffffffffff",3181 .source = "-0x1ffffffffffffffff",
3182 .errors = &errors,3182 .diagnostics = &diagnostics,
3183 }));3183 }));
3184 try std.testing.expectEqual(@as(u65, 0x1ffffffffffffffff), try fromSliceNoAlloc(u65, .{3184 try std.testing.expectEqual(@as(u65, 0x1ffffffffffffffff), try fromSliceNoAlloc(u65, .{
3185 .gpa = gpa,3185 .gpa = gpa,
3186 .arena = arena,3186 .arena = arena,
3187 .source = "0o3777777777777777777777",3187 .source = "0o3777777777777777777777",
3188 .errors = &errors,3188 .diagnostics = &diagnostics,
3189 }));3189 }));
3190 try std.testing.expectEqual(@as(i66, 0x1ffffffffffffffff), try fromSliceNoAlloc(i66, .{3190 try std.testing.expectEqual(@as(i66, 0x1ffffffffffffffff), try fromSliceNoAlloc(i66, .{
3191 .gpa = gpa,3191 .gpa = gpa,
3192 .arena = arena,3192 .arena = arena,
3193 .source = "0o3777777777777777777777",3193 .source = "0o3777777777777777777777",
3194 .errors = &errors,3194 .diagnostics = &diagnostics,
3195 }));3195 }));
3196 try std.testing.expectEqual(@as(i66, -0x1ffffffffffffffff), try fromSliceNoAlloc(i66, .{3196 try std.testing.expectEqual(@as(i66, -0x1ffffffffffffffff), try fromSliceNoAlloc(i66, .{
3197 .gpa = gpa,3197 .gpa = gpa,
3198 .arena = arena,3198 .arena = arena,
3199 .source = "-0o3777777777777777777777",3199 .source = "-0o3777777777777777777777",
3200 .errors = &errors,3200 .diagnostics = &diagnostics,
3201 }));3201 }));
3202 try std.testing.expectEqual(@as(u65, 0x1ffffffffffffffff), try fromSliceNoAlloc(u65, .{3202 try std.testing.expectEqual(@as(u65, 0x1ffffffffffffffff), try fromSliceNoAlloc(u65, .{
3203 .gpa = gpa,3203 .gpa = gpa,
3204 .arena = arena,3204 .arena = arena,
3205 .source = "0b11111111111111111111111111111111111111111111111111111111111111111",3205 .source = "0b11111111111111111111111111111111111111111111111111111111111111111",
3206 .errors = &errors,3206 .diagnostics = &diagnostics,
3207 }));3207 }));
3208 try std.testing.expectEqual(@as(i66, 0x1ffffffffffffffff), try fromSliceNoAlloc(i66, .{3208 try std.testing.expectEqual(@as(i66, 0x1ffffffffffffffff), try fromSliceNoAlloc(i66, .{
3209 .gpa = gpa,3209 .gpa = gpa,
3210 .arena = arena,3210 .arena = arena,
3211 .source = "0b11111111111111111111111111111111111111111111111111111111111111111",3211 .source = "0b11111111111111111111111111111111111111111111111111111111111111111",
3212 .errors = &errors,3212 .diagnostics = &diagnostics,
3213 }));3213 }));
3214 try std.testing.expectEqual(@as(i66, -0x1ffffffffffffffff), try fromSliceNoAlloc(i66, .{3214 try std.testing.expectEqual(@as(i66, -0x1ffffffffffffffff), try fromSliceNoAlloc(i66, .{
3215 .gpa = gpa,3215 .gpa = gpa,
3216 .arena = arena,3216 .arena = arena,
3217 .source = "-0b11111111111111111111111111111111111111111111111111111111111111111",3217 .source = "-0b11111111111111111111111111111111111111111111111111111111111111111",
3218 .errors = &errors,3218 .diagnostics = &diagnostics,
3219 }));3219 }));
32203220
3221 // Number with invalid character in the middle3221 // Number with invalid character in the middle
...@@ -3224,12 +3224,12 @@ test "std.zon parse int" {...@@ -3224,12 +3224,12 @@ test "std.zon parse int" {
3224 .gpa = gpa,3224 .gpa = gpa,
3225 .arena = arena,3225 .arena = arena,
3226 .source = "32a32",3226 .source = "32a32",
3227 .errors = &errors,3227 .diagnostics = &diagnostics,
3228 }));3228 }));
3229 try std.testing.expectFmt(3229 try std.testing.expectFmt(
3230 \\input.zon:1:3: error: invalid digit 'a' for decimal base3230 \\input.zon:1:3: error: invalid digit 'a' for decimal base
3231 \\3231 \\
3232 , "{f}", .{errors.fmt("input.zon")});3232 , "{f}", .{diagnostics.fmt("input.zon")});
3233 }3233 }
32343234
3235 // Failing to parse as int3235 // Failing to parse as int
...@@ -3238,12 +3238,12 @@ test "std.zon parse int" {...@@ -3238,12 +3238,12 @@ test "std.zon parse int" {
3238 .gpa = gpa,3238 .gpa = gpa,
3239 .arena = arena,3239 .arena = arena,
3240 .source = "true",3240 .source = "true",
3241 .errors = &errors,3241 .diagnostics = &diagnostics,
3242 }));3242 }));
3243 try std.testing.expectFmt(3243 try std.testing.expectFmt(
3244 \\input.zon:1:1: error: expected type 'u8'3244 \\input.zon:1:1: error: expected type 'u8'
3245 \\3245 \\
3246 , "{f}", .{errors.fmt("input.zon")});3246 , "{f}", .{diagnostics.fmt("input.zon")});
3247 }3247 }
32483248
3249 // Failing because an int is out of range3249 // Failing because an int is out of range
...@@ -3252,12 +3252,12 @@ test "std.zon parse int" {...@@ -3252,12 +3252,12 @@ test "std.zon parse int" {
3252 .gpa = gpa,3252 .gpa = gpa,
3253 .arena = arena,3253 .arena = arena,
3254 .source = "256",3254 .source = "256",
3255 .errors = &errors,3255 .diagnostics = &diagnostics,
3256 }));3256 }));
3257 try std.testing.expectFmt(3257 try std.testing.expectFmt(
3258 \\input.zon:1:1: error: type 'u8' cannot represent value3258 \\input.zon:1:1: error: type 'u8' cannot represent value
3259 \\3259 \\
3260 , "{f}", .{errors.fmt("input.zon")});3260 , "{f}", .{diagnostics.fmt("input.zon")});
3261 }3261 }
32623262
3263 // Failing because a negative int is out of range3263 // Failing because a negative int is out of range
...@@ -3266,12 +3266,12 @@ test "std.zon parse int" {...@@ -3266,12 +3266,12 @@ test "std.zon parse int" {
3266 .gpa = gpa,3266 .gpa = gpa,
3267 .arena = arena,3267 .arena = arena,
3268 .source = "-129",3268 .source = "-129",
3269 .errors = &errors,3269 .diagnostics = &diagnostics,
3270 }));3270 }));
3271 try std.testing.expectFmt(3271 try std.testing.expectFmt(
3272 \\input.zon:1:1: error: type 'i8' cannot represent value3272 \\input.zon:1:1: error: type 'i8' cannot represent value
3273 \\3273 \\
3274 , "{f}", .{errors.fmt("input.zon")});3274 , "{f}", .{diagnostics.fmt("input.zon")});
3275 }3275 }
32763276
3277 // Failing because an unsigned int is negative3277 // Failing because an unsigned int is negative
...@@ -3280,12 +3280,12 @@ test "std.zon parse int" {...@@ -3280,12 +3280,12 @@ test "std.zon parse int" {
3280 .gpa = gpa,3280 .gpa = gpa,
3281 .arena = arena,3281 .arena = arena,
3282 .source = "-1",3282 .source = "-1",
3283 .errors = &errors,3283 .diagnostics = &diagnostics,
3284 }));3284 }));
3285 try std.testing.expectFmt(3285 try std.testing.expectFmt(
3286 \\input.zon:1:1: error: type 'u8' cannot represent value3286 \\input.zon:1:1: error: type 'u8' cannot represent value
3287 \\3287 \\
3288 , "{f}", .{errors.fmt("input.zon")});3288 , "{f}", .{diagnostics.fmt("input.zon")});
3289 }3289 }
32903290
3291 // Failing because a float is non-whole3291 // Failing because a float is non-whole
...@@ -3294,12 +3294,12 @@ test "std.zon parse int" {...@@ -3294,12 +3294,12 @@ test "std.zon parse int" {
3294 .gpa = gpa,3294 .gpa = gpa,
3295 .arena = arena,3295 .arena = arena,
3296 .source = "1.5",3296 .source = "1.5",
3297 .errors = &errors,3297 .diagnostics = &diagnostics,
3298 }));3298 }));
3299 try std.testing.expectFmt(3299 try std.testing.expectFmt(
3300 \\input.zon:1:1: error: type 'u8' cannot represent value3300 \\input.zon:1:1: error: type 'u8' cannot represent value
3301 \\3301 \\
3302 , "{f}", .{errors.fmt("input.zon")});3302 , "{f}", .{diagnostics.fmt("input.zon")});
3303 }3303 }
33043304
3305 // Failing because a float is negative3305 // Failing because a float is negative
...@@ -3308,12 +3308,12 @@ test "std.zon parse int" {...@@ -3308,12 +3308,12 @@ test "std.zon parse int" {
3308 .gpa = gpa,3308 .gpa = gpa,
3309 .arena = arena,3309 .arena = arena,
3310 .source = "-1.0",3310 .source = "-1.0",
3311 .errors = &errors,3311 .diagnostics = &diagnostics,
3312 }));3312 }));
3313 try std.testing.expectFmt(3313 try std.testing.expectFmt(
3314 \\input.zon:1:1: error: type 'u8' cannot represent value3314 \\input.zon:1:1: error: type 'u8' cannot represent value
3315 \\3315 \\
3316 , "{f}", .{errors.fmt("input.zon")});3316 , "{f}", .{diagnostics.fmt("input.zon")});
3317 }3317 }
33183318
3319 // Negative integer zero3319 // Negative integer zero
...@@ -3322,14 +3322,14 @@ test "std.zon parse int" {...@@ -3322,14 +3322,14 @@ test "std.zon parse int" {
3322 .gpa = gpa,3322 .gpa = gpa,
3323 .arena = arena,3323 .arena = arena,
3324 .source = "-0",3324 .source = "-0",
3325 .errors = &errors,3325 .diagnostics = &diagnostics,
3326 }));3326 }));
3327 try std.testing.expectFmt(3327 try std.testing.expectFmt(
3328 \\input.zon:1:2: error: integer literal '-0' is ambiguous3328 \\input.zon:1:2: error: integer literal '-0' is ambiguous
3329 \\input.zon:1:2: note: use '0' for an integer zero3329 \\input.zon:1:2: note: use '0' for an integer zero
3330 \\input.zon:1:2: note: use '-0.0' for a floating-point signed zero3330 \\input.zon:1:2: note: use '-0.0' for a floating-point signed zero
3331 \\3331 \\
3332 , "{f}", .{errors.fmt("input.zon")});3332 , "{f}", .{diagnostics.fmt("input.zon")});
3333 }3333 }
33343334
3335 // Negative integer zero casted to float3335 // Negative integer zero casted to float
...@@ -3338,14 +3338,14 @@ test "std.zon parse int" {...@@ -3338,14 +3338,14 @@ test "std.zon parse int" {
3338 .gpa = gpa,3338 .gpa = gpa,
3339 .arena = arena,3339 .arena = arena,
3340 .source = "-0",3340 .source = "-0",
3341 .errors = &errors,3341 .diagnostics = &diagnostics,
3342 }));3342 }));
3343 try std.testing.expectFmt(3343 try std.testing.expectFmt(
3344 \\input.zon:1:2: error: integer literal '-0' is ambiguous3344 \\input.zon:1:2: error: integer literal '-0' is ambiguous
3345 \\input.zon:1:2: note: use '0' for an integer zero3345 \\input.zon:1:2: note: use '0' for an integer zero
3346 \\input.zon:1:2: note: use '-0.0' for a floating-point signed zero3346 \\input.zon:1:2: note: use '-0.0' for a floating-point signed zero
3347 \\3347 \\
3348 , "{f}", .{errors.fmt("input.zon")});3348 , "{f}", .{diagnostics.fmt("input.zon")});
3349 }3349 }
33503350
3351 // Negative float 0 is allowed3351 // Negative float 0 is allowed
...@@ -3354,14 +3354,14 @@ test "std.zon parse int" {...@@ -3354,14 +3354,14 @@ test "std.zon parse int" {
3354 .gpa = gpa,3354 .gpa = gpa,
3355 .arena = arena,3355 .arena = arena,
3356 .source = "-0.0",3356 .source = "-0.0",
3357 .errors = &errors,3357 .diagnostics = &diagnostics,
3358 })),3358 })),
3359 );3359 );
3360 try std.testing.expect(std.math.isPositiveZero(try fromSliceNoAlloc(f32, .{3360 try std.testing.expect(std.math.isPositiveZero(try fromSliceNoAlloc(f32, .{
3361 .gpa = gpa,3361 .gpa = gpa,
3362 .arena = arena,3362 .arena = arena,
3363 .source = "0.0",3363 .source = "0.0",
3364 .errors = &errors,3364 .diagnostics = &diagnostics,
3365 })));3365 })));
33663366
3367 // Double negation is not allowed3367 // Double negation is not allowed
...@@ -3370,12 +3370,12 @@ test "std.zon parse int" {...@@ -3370,12 +3370,12 @@ test "std.zon parse int" {
3370 .gpa = gpa,3370 .gpa = gpa,
3371 .arena = arena,3371 .arena = arena,
3372 .source = "--2",3372 .source = "--2",
3373 .errors = &errors,3373 .diagnostics = &diagnostics,
3374 }));3374 }));
3375 try std.testing.expectFmt(3375 try std.testing.expectFmt(
3376 \\input.zon:1:1: error: expected number or 'inf' after '-'3376 \\input.zon:1:1: error: expected number or 'inf' after '-'
3377 \\3377 \\
3378 , "{f}", .{errors.fmt("input.zon")});3378 , "{f}", .{diagnostics.fmt("input.zon")});
3379 }3379 }
33803380
3381 {3381 {
...@@ -3385,13 +3385,13 @@ test "std.zon parse int" {...@@ -3385,13 +3385,13 @@ test "std.zon parse int" {
3385 .gpa = gpa,3385 .gpa = gpa,
3386 .arena = arena,3386 .arena = arena,
3387 .source = "--2.0",3387 .source = "--2.0",
3388 .errors = &errors,3388 .diagnostics = &diagnostics,
3389 }),3389 }),
3390 );3390 );
3391 try std.testing.expectFmt(3391 try std.testing.expectFmt(
3392 \\input.zon:1:1: error: expected number or 'inf' after '-'3392 \\input.zon:1:1: error: expected number or 'inf' after '-'
3393 \\3393 \\
3394 , "{f}", .{errors.fmt("input.zon")});3394 , "{f}", .{diagnostics.fmt("input.zon")});
3395 }3395 }
33963396
3397 // Invalid int literal3397 // Invalid int literal
...@@ -3400,12 +3400,12 @@ test "std.zon parse int" {...@@ -3400,12 +3400,12 @@ test "std.zon parse int" {
3400 .gpa = gpa,3400 .gpa = gpa,
3401 .arena = arena,3401 .arena = arena,
3402 .source = "0xg",3402 .source = "0xg",
3403 .errors = &errors,3403 .diagnostics = &diagnostics,
3404 }));3404 }));
3405 try std.testing.expectFmt(3405 try std.testing.expectFmt(
3406 \\input.zon:1:3: error: invalid digit 'g' for hex base3406 \\input.zon:1:3: error: invalid digit 'g' for hex base
3407 \\3407 \\
3408 , "{f}", .{errors.fmt("input.zon")});3408 , "{f}", .{diagnostics.fmt("input.zon")});
3409 }3409 }
34103410
3411 // Notes on invalid int literal3411 // Notes on invalid int literal
...@@ -3414,13 +3414,13 @@ test "std.zon parse int" {...@@ -3414,13 +3414,13 @@ test "std.zon parse int" {
3414 .gpa = gpa,3414 .gpa = gpa,
3415 .arena = arena,3415 .arena = arena,
3416 .source = "0123",3416 .source = "0123",
3417 .errors = &errors,3417 .diagnostics = &diagnostics,
3418 }));3418 }));
3419 try std.testing.expectFmt(3419 try std.testing.expectFmt(
3420 \\input.zon:1:1: error: number '0123' has leading zero3420 \\input.zon:1:1: error: number '0123' has leading zero
3421 \\input.zon:1:1: note: use '0o' prefix for octal literals3421 \\input.zon:1:1: note: use '0o' prefix for octal literals
3422 \\3422 \\
3423 , "{f}", .{errors.fmt("input.zon")});3423 , "{f}", .{diagnostics.fmt("input.zon")});
3424 }3424 }
3425}3425}
34263426
...@@ -3429,31 +3429,31 @@ test "std.zon negative char" {...@@ -3429,31 +3429,31 @@ test "std.zon negative char" {
3429 var arena_allocator: ArenaAllocator = .init(gpa);3429 var arena_allocator: ArenaAllocator = .init(gpa);
3430 defer arena_allocator.deinit();3430 defer arena_allocator.deinit();
3431 const arena = arena_allocator.allocator();3431 const arena = arena_allocator.allocator();
3432 var errors: Errors = .empty;3432 var diagnostics: Diagnostics = .empty;
34333433
3434 {3434 {
3435 try std.testing.expectError(error.ParseZon, fromSliceNoAlloc(f32, .{3435 try std.testing.expectError(error.ParseZon, fromSliceNoAlloc(f32, .{
3436 .gpa = gpa,3436 .gpa = gpa,
3437 .arena = arena,3437 .arena = arena,
3438 .source = "-'a'",3438 .source = "-'a'",
3439 .errors = &errors,3439 .diagnostics = &diagnostics,
3440 }));3440 }));
3441 try std.testing.expectFmt(3441 try std.testing.expectFmt(
3442 \\input.zon:1:1: error: expected number or 'inf' after '-'3442 \\input.zon:1:1: error: expected number or 'inf' after '-'
3443 \\3443 \\
3444 , "{f}", .{errors.fmt("input.zon")});3444 , "{f}", .{diagnostics.fmt("input.zon")});
3445 }3445 }
3446 {3446 {
3447 try std.testing.expectError(error.ParseZon, fromSliceNoAlloc(i16, .{3447 try std.testing.expectError(error.ParseZon, fromSliceNoAlloc(i16, .{
3448 .gpa = gpa,3448 .gpa = gpa,
3449 .arena = arena,3449 .arena = arena,
3450 .source = "-'a'",3450 .source = "-'a'",
3451 .errors = &errors,3451 .diagnostics = &diagnostics,
3452 }));3452 }));
3453 try std.testing.expectFmt(3453 try std.testing.expectFmt(
3454 \\input.zon:1:1: error: expected number or 'inf' after '-'3454 \\input.zon:1:1: error: expected number or 'inf' after '-'
3455 \\3455 \\
3456 , "{f}", .{errors.fmt("input.zon")});3456 , "{f}", .{diagnostics.fmt("input.zon")});
3457 }3457 }
3458}3458}
34593459
...@@ -3464,14 +3464,14 @@ test "std.zon parse float" {...@@ -3464,14 +3464,14 @@ test "std.zon parse float" {
3464 var arena_allocator: ArenaAllocator = .init(gpa);3464 var arena_allocator: ArenaAllocator = .init(gpa);
3465 defer arena_allocator.deinit();3465 defer arena_allocator.deinit();
3466 const arena = arena_allocator.allocator();3466 const arena = arena_allocator.allocator();
3467 var errors: Errors = .empty;3467 var diagnostics: Diagnostics = .empty;
34683468
3469 // Test decimals3469 // Test decimals
3470 try std.testing.expectEqual(@as(f16, 0.5), try fromSliceNoAlloc(f16, .{3470 try std.testing.expectEqual(@as(f16, 0.5), try fromSliceNoAlloc(f16, .{
3471 .gpa = gpa,3471 .gpa = gpa,
3472 .arena = arena,3472 .arena = arena,
3473 .source = "0.5",3473 .source = "0.5",
3474 .errors = &errors,3474 .diagnostics = &diagnostics,
3475 }));3475 }));
3476 try std.testing.expectEqual(3476 try std.testing.expectEqual(
3477 @as(f32, 123.456),3477 @as(f32, 123.456),
...@@ -3479,7 +3479,7 @@ test "std.zon parse float" {...@@ -3479,7 +3479,7 @@ test "std.zon parse float" {
3479 .gpa = gpa,3479 .gpa = gpa,
3480 .arena = arena,3480 .arena = arena,
3481 .source = "123.456",3481 .source = "123.456",
3482 .errors = &errors,3482 .diagnostics = &diagnostics,
3483 }),3483 }),
3484 );3484 );
3485 try std.testing.expectEqual(3485 try std.testing.expectEqual(
...@@ -3488,14 +3488,14 @@ test "std.zon parse float" {...@@ -3488,14 +3488,14 @@ test "std.zon parse float" {
3488 .gpa = gpa,3488 .gpa = gpa,
3489 .arena = arena,3489 .arena = arena,
3490 .source = "-123.456",3490 .source = "-123.456",
3491 .errors = &errors,3491 .diagnostics = &diagnostics,
3492 }),3492 }),
3493 );3493 );
3494 try std.testing.expectEqual(@as(f128, 42.5), try fromSliceNoAlloc(f128, .{3494 try std.testing.expectEqual(@as(f128, 42.5), try fromSliceNoAlloc(f128, .{
3495 .gpa = gpa,3495 .gpa = gpa,
3496 .arena = arena,3496 .arena = arena,
3497 .source = "42.5",3497 .source = "42.5",
3498 .errors = &errors,3498 .diagnostics = &diagnostics,
3499 }));3499 }));
35003500
3501 // Test whole numbers with and without decimals3501 // Test whole numbers with and without decimals
...@@ -3503,25 +3503,25 @@ test "std.zon parse float" {...@@ -3503,25 +3503,25 @@ test "std.zon parse float" {
3503 .gpa = gpa,3503 .gpa = gpa,
3504 .arena = arena,3504 .arena = arena,
3505 .source = "5.0",3505 .source = "5.0",
3506 .errors = &errors,3506 .diagnostics = &diagnostics,
3507 }));3507 }));
3508 try std.testing.expectEqual(@as(f16, 5.0), try fromSliceNoAlloc(f16, .{3508 try std.testing.expectEqual(@as(f16, 5.0), try fromSliceNoAlloc(f16, .{
3509 .gpa = gpa,3509 .gpa = gpa,
3510 .arena = arena,3510 .arena = arena,
3511 .source = "5",3511 .source = "5",
3512 .errors = &errors,3512 .diagnostics = &diagnostics,
3513 }));3513 }));
3514 try std.testing.expectEqual(@as(f32, -102), try fromSliceNoAlloc(f32, .{3514 try std.testing.expectEqual(@as(f32, -102), try fromSliceNoAlloc(f32, .{
3515 .gpa = gpa,3515 .gpa = gpa,
3516 .arena = arena,3516 .arena = arena,
3517 .source = "-102.0",3517 .source = "-102.0",
3518 .errors = &errors,3518 .diagnostics = &diagnostics,
3519 }));3519 }));
3520 try std.testing.expectEqual(@as(f32, -102), try fromSliceNoAlloc(f32, .{3520 try std.testing.expectEqual(@as(f32, -102), try fromSliceNoAlloc(f32, .{
3521 .gpa = gpa,3521 .gpa = gpa,
3522 .arena = arena,3522 .arena = arena,
3523 .source = "-102",3523 .source = "-102",
3524 .errors = &errors,3524 .diagnostics = &diagnostics,
3525 }));3525 }));
35263526
3527 // Test characters and negated characters3527 // Test characters and negated characters
...@@ -3529,13 +3529,13 @@ test "std.zon parse float" {...@@ -3529,13 +3529,13 @@ test "std.zon parse float" {
3529 .gpa = gpa,3529 .gpa = gpa,
3530 .arena = arena,3530 .arena = arena,
3531 .source = "'a'",3531 .source = "'a'",
3532 .errors = &errors,3532 .diagnostics = &diagnostics,
3533 }));3533 }));
3534 try std.testing.expectEqual(@as(f32, 'z'), try fromSliceNoAlloc(f32, .{3534 try std.testing.expectEqual(@as(f32, 'z'), try fromSliceNoAlloc(f32, .{
3535 .gpa = gpa,3535 .gpa = gpa,
3536 .arena = arena,3536 .arena = arena,
3537 .source = "'z'",3537 .source = "'z'",
3538 .errors = &errors,3538 .diagnostics = &diagnostics,
3539 }));3539 }));
35403540
3541 // Test big integers3541 // Test big integers
...@@ -3545,7 +3545,7 @@ test "std.zon parse float" {...@@ -3545,7 +3545,7 @@ test "std.zon parse float" {
3545 .gpa = gpa,3545 .gpa = gpa,
3546 .arena = arena,3546 .arena = arena,
3547 .source = "36893488147419103231",3547 .source = "36893488147419103231",
3548 .errors = &errors,3548 .diagnostics = &diagnostics,
3549 }),3549 }),
3550 );3550 );
3551 try std.testing.expectEqual(3551 try std.testing.expectEqual(
...@@ -3554,20 +3554,20 @@ test "std.zon parse float" {...@@ -3554,20 +3554,20 @@ test "std.zon parse float" {
3554 .gpa = gpa,3554 .gpa = gpa,
3555 .arena = arena,3555 .arena = arena,
3556 .source = "-36893488147419103231",3556 .source = "-36893488147419103231",
3557 .errors = &errors,3557 .diagnostics = &diagnostics,
3558 }),3558 }),
3559 );3559 );
3560 try std.testing.expectEqual(@as(f128, 0x1ffffffffffffffff), try fromSliceNoAlloc(f128, .{3560 try std.testing.expectEqual(@as(f128, 0x1ffffffffffffffff), try fromSliceNoAlloc(f128, .{
3561 .gpa = gpa,3561 .gpa = gpa,
3562 .arena = arena,3562 .arena = arena,
3563 .source = "0x1ffffffffffffffff",3563 .source = "0x1ffffffffffffffff",
3564 .errors = &errors,3564 .diagnostics = &diagnostics,
3565 }));3565 }));
3566 try std.testing.expectEqual(@as(f32, @floatFromInt(0x1ffffffffffffffff)), try fromSliceNoAlloc(f32, .{3566 try std.testing.expectEqual(@as(f32, @floatFromInt(0x1ffffffffffffffff)), try fromSliceNoAlloc(f32, .{
3567 .gpa = gpa,3567 .gpa = gpa,
3568 .arena = arena,3568 .arena = arena,
3569 .source = "0x1ffffffffffffffff",3569 .source = "0x1ffffffffffffffff",
3570 .errors = &errors,3570 .diagnostics = &diagnostics,
3571 }));3571 }));
35723572
3573 // Exponents, underscores3573 // Exponents, underscores
...@@ -3577,7 +3577,7 @@ test "std.zon parse float" {...@@ -3577,7 +3577,7 @@ test "std.zon parse float" {
3577 .gpa = gpa,3577 .gpa = gpa,
3578 .arena = arena,3578 .arena = arena,
3579 .source = "12_3.0E+77",3579 .source = "12_3.0E+77",
3580 .errors = &errors,3580 .diagnostics = &diagnostics,
3581 }),3581 }),
3582 );3582 );
35833583
...@@ -3588,7 +3588,7 @@ test "std.zon parse float" {...@@ -3588,7 +3588,7 @@ test "std.zon parse float" {
3588 .gpa = gpa,3588 .gpa = gpa,
3589 .arena = arena,3589 .arena = arena,
3590 .source = "0x103.70p-5",3590 .source = "0x103.70p-5",
3591 .errors = &errors,3591 .diagnostics = &diagnostics,
3592 }),3592 }),
3593 );3593 );
3594 try std.testing.expectEqual(3594 try std.testing.expectEqual(
...@@ -3597,7 +3597,7 @@ test "std.zon parse float" {...@@ -3597,7 +3597,7 @@ test "std.zon parse float" {
3597 .gpa = gpa,3597 .gpa = gpa,
3598 .arena = arena,3598 .arena = arena,
3599 .source = "-0x103.70",3599 .source = "-0x103.70",
3600 .errors = &errors,3600 .diagnostics = &diagnostics,
3601 }),3601 }),
3602 );3602 );
3603 try std.testing.expectEqual(3603 try std.testing.expectEqual(
...@@ -3606,7 +3606,7 @@ test "std.zon parse float" {...@@ -3606,7 +3606,7 @@ test "std.zon parse float" {
3606 .gpa = gpa,3606 .gpa = gpa,
3607 .arena = arena,3607 .arena = arena,
3608 .source = "0x1234_5678.9ABC_CDEFp-10",3608 .source = "0x1234_5678.9ABC_CDEFp-10",
3609 .errors = &errors,3609 .diagnostics = &diagnostics,
3610 }),3610 }),
3611 );3611 );
36123612
...@@ -3615,19 +3615,19 @@ test "std.zon parse float" {...@@ -3615,19 +3615,19 @@ test "std.zon parse float" {
3615 .gpa = gpa,3615 .gpa = gpa,
3616 .arena = arena,3616 .arena = arena,
3617 .source = "inf",3617 .source = "inf",
3618 .errors = &errors,3618 .diagnostics = &diagnostics,
3619 })));3619 })));
3620 try std.testing.expect(std.math.isNegativeInf(try fromSliceNoAlloc(f32, .{3620 try std.testing.expect(std.math.isNegativeInf(try fromSliceNoAlloc(f32, .{
3621 .gpa = gpa,3621 .gpa = gpa,
3622 .arena = arena,3622 .arena = arena,
3623 .source = "-inf",3623 .source = "-inf",
3624 .errors = &errors,3624 .diagnostics = &diagnostics,
3625 })));3625 })));
3626 try std.testing.expect(std.math.isNan(try fromSliceNoAlloc(f32, .{3626 try std.testing.expect(std.math.isNan(try fromSliceNoAlloc(f32, .{
3627 .gpa = gpa,3627 .gpa = gpa,
3628 .arena = arena,3628 .arena = arena,
3629 .source = "nan",3629 .source = "nan",
3630 .errors = &errors,3630 .diagnostics = &diagnostics,
3631 })));3631 })));
36323632
3633 // Negative nan not allowed3633 // Negative nan not allowed
...@@ -3636,12 +3636,12 @@ test "std.zon parse float" {...@@ -3636,12 +3636,12 @@ test "std.zon parse float" {
3636 .gpa = gpa,3636 .gpa = gpa,
3637 .arena = arena,3637 .arena = arena,
3638 .source = "-nan",3638 .source = "-nan",
3639 .errors = &errors,3639 .diagnostics = &diagnostics,
3640 }));3640 }));
3641 try std.testing.expectFmt(3641 try std.testing.expectFmt(
3642 \\input.zon:1:1: error: expected number or 'inf' after '-'3642 \\input.zon:1:1: error: expected number or 'inf' after '-'
3643 \\3643 \\
3644 , "{f}", .{errors.fmt("input.zon")});3644 , "{f}", .{diagnostics.fmt("input.zon")});
3645 }3645 }
36463646
3647 // nan as int not allowed3647 // nan as int not allowed
...@@ -3650,12 +3650,12 @@ test "std.zon parse float" {...@@ -3650,12 +3650,12 @@ test "std.zon parse float" {
3650 .gpa = gpa,3650 .gpa = gpa,
3651 .arena = arena,3651 .arena = arena,
3652 .source = "nan",3652 .source = "nan",
3653 .errors = &errors,3653 .diagnostics = &diagnostics,
3654 }));3654 }));
3655 try std.testing.expectFmt(3655 try std.testing.expectFmt(
3656 \\input.zon:1:1: error: expected type 'i8'3656 \\input.zon:1:1: error: expected type 'i8'
3657 \\3657 \\
3658 , "{f}", .{errors.fmt("input.zon")});3658 , "{f}", .{diagnostics.fmt("input.zon")});
3659 }3659 }
36603660
3661 // nan as int not allowed3661 // nan as int not allowed
...@@ -3664,12 +3664,12 @@ test "std.zon parse float" {...@@ -3664,12 +3664,12 @@ test "std.zon parse float" {
3664 .gpa = gpa,3664 .gpa = gpa,
3665 .arena = arena,3665 .arena = arena,
3666 .source = "nan",3666 .source = "nan",
3667 .errors = &errors,3667 .diagnostics = &diagnostics,
3668 }));3668 }));
3669 try std.testing.expectFmt(3669 try std.testing.expectFmt(
3670 \\input.zon:1:1: error: expected type 'i8'3670 \\input.zon:1:1: error: expected type 'i8'
3671 \\3671 \\
3672 , "{f}", .{errors.fmt("input.zon")});3672 , "{f}", .{diagnostics.fmt("input.zon")});
3673 }3673 }
36743674
3675 // inf as int not allowed3675 // inf as int not allowed
...@@ -3678,12 +3678,12 @@ test "std.zon parse float" {...@@ -3678,12 +3678,12 @@ test "std.zon parse float" {
3678 .gpa = gpa,3678 .gpa = gpa,
3679 .arena = arena,3679 .arena = arena,
3680 .source = "inf",3680 .source = "inf",
3681 .errors = &errors,3681 .diagnostics = &diagnostics,
3682 }));3682 }));
3683 try std.testing.expectFmt(3683 try std.testing.expectFmt(
3684 \\input.zon:1:1: error: expected type 'i8'3684 \\input.zon:1:1: error: expected type 'i8'
3685 \\3685 \\
3686 , "{f}", .{errors.fmt("input.zon")});3686 , "{f}", .{diagnostics.fmt("input.zon")});
3687 }3687 }
36883688
3689 // -inf as int not allowed3689 // -inf as int not allowed
...@@ -3692,12 +3692,12 @@ test "std.zon parse float" {...@@ -3692,12 +3692,12 @@ test "std.zon parse float" {
3692 .gpa = gpa,3692 .gpa = gpa,
3693 .arena = arena,3693 .arena = arena,
3694 .source = "-inf",3694 .source = "-inf",
3695 .errors = &errors,3695 .diagnostics = &diagnostics,
3696 }));3696 }));
3697 try std.testing.expectFmt(3697 try std.testing.expectFmt(
3698 \\input.zon:1:1: error: expected type 'i8'3698 \\input.zon:1:1: error: expected type 'i8'
3699 \\3699 \\
3700 , "{f}", .{errors.fmt("input.zon")});3700 , "{f}", .{diagnostics.fmt("input.zon")});
3701 }3701 }
37023702
3703 // Bad identifier as float3703 // Bad identifier as float
...@@ -3706,14 +3706,14 @@ test "std.zon parse float" {...@@ -3706,14 +3706,14 @@ test "std.zon parse float" {
3706 .gpa = gpa,3706 .gpa = gpa,
3707 .arena = arena,3707 .arena = arena,
3708 .source = "foo",3708 .source = "foo",
3709 .errors = &errors,3709 .diagnostics = &diagnostics,
3710 }));3710 }));
3711 try std.testing.expectFmt(3711 try std.testing.expectFmt(
3712 \\input.zon:1:1: error: invalid expression3712 \\input.zon:1:1: error: invalid expression
3713 \\input.zon:1:1: note: ZON allows identifiers 'true', 'false', 'null', 'inf', and 'nan'3713 \\input.zon:1:1: note: ZON allows identifiers 'true', 'false', 'null', 'inf', and 'nan'
3714 \\input.zon:1:1: note: precede identifier with '.' for an enum literal3714 \\input.zon:1:1: note: precede identifier with '.' for an enum literal
3715 \\3715 \\
3716 , "{f}", .{errors.fmt("input.zon")});3716 , "{f}", .{diagnostics.fmt("input.zon")});
3717 }3717 }
37183718
3719 {3719 {
...@@ -3721,12 +3721,12 @@ test "std.zon parse float" {...@@ -3721,12 +3721,12 @@ test "std.zon parse float" {
3721 .gpa = gpa,3721 .gpa = gpa,
3722 .arena = arena,3722 .arena = arena,
3723 .source = "-foo",3723 .source = "-foo",
3724 .errors = &errors,3724 .diagnostics = &diagnostics,
3725 }));3725 }));
3726 try std.testing.expectFmt(3726 try std.testing.expectFmt(
3727 \\input.zon:1:1: error: expected number or 'inf' after '-'3727 \\input.zon:1:1: error: expected number or 'inf' after '-'
3728 \\3728 \\
3729 , "{f}", .{errors.fmt("input.zon")});3729 , "{f}", .{diagnostics.fmt("input.zon")});
3730 }3730 }
37313731
3732 // Non float as float3732 // Non float as float
...@@ -3737,13 +3737,13 @@ test "std.zon parse float" {...@@ -3737,13 +3737,13 @@ test "std.zon parse float" {
3737 .gpa = gpa,3737 .gpa = gpa,
3738 .arena = arena,3738 .arena = arena,
3739 .source = "\"foo\"",3739 .source = "\"foo\"",
3740 .errors = &errors,3740 .diagnostics = &diagnostics,
3741 }),3741 }),
3742 );3742 );
3743 try std.testing.expectFmt(3743 try std.testing.expectFmt(
3744 \\input.zon:1:1: error: expected type 'f32'3744 \\input.zon:1:1: error: expected type 'f32'
3745 \\3745 \\
3746 , "{f}", .{errors.fmt("input.zon")});3746 , "{f}", .{diagnostics.fmt("input.zon")});
3747 }3747 }
3748}3748}
37493749
...@@ -3752,7 +3752,7 @@ test "std.zon free on error" {...@@ -3752,7 +3752,7 @@ test "std.zon free on error" {
3752 var arena_allocator: ArenaAllocator = .init(gpa);3752 var arena_allocator: ArenaAllocator = .init(gpa);
3753 defer arena_allocator.deinit();3753 defer arena_allocator.deinit();
3754 const arena = arena_allocator.allocator();3754 const arena = arena_allocator.allocator();
3755 var errors: Errors = .empty;3755 var diagnostics: Diagnostics = .empty;
37563756
3757 // Test freeing partially allocated structs3757 // Test freeing partially allocated structs
3758 {3758 {
...@@ -3771,7 +3771,7 @@ test "std.zon free on error" {...@@ -3771,7 +3771,7 @@ test "std.zon free on error" {
3771 \\ .z = "fail",3771 \\ .z = "fail",
3772 \\}3772 \\}
3773 ,3773 ,
3774 .errors = &errors,3774 .diagnostics = &diagnostics,
3775 }));3775 }));
3776 }3776 }
37773777
...@@ -3792,7 +3792,7 @@ test "std.zon free on error" {...@@ -3792,7 +3792,7 @@ test "std.zon free on error" {
3792 \\ "fail",3792 \\ "fail",
3793 \\}3793 \\}
3794 ,3794 ,
3795 .errors = &errors,3795 .diagnostics = &diagnostics,
3796 }));3796 }));
3797 }3797 }
37983798
...@@ -3809,7 +3809,7 @@ test "std.zon free on error" {...@@ -3809,7 +3809,7 @@ test "std.zon free on error" {
3809 \\ .x = "hello",3809 \\ .x = "hello",
3810 \\}3810 \\}
3811 ,3811 ,
3812 .errors = &errors,3812 .diagnostics = &diagnostics,
3813 }));3813 }));
38143814
3815 // Test freeing partially allocated arrays3815 // Test freeing partially allocated arrays
...@@ -3823,7 +3823,7 @@ test "std.zon free on error" {...@@ -3823,7 +3823,7 @@ test "std.zon free on error" {
3823 \\ false,3823 \\ false,
3824 \\}3824 \\}
3825 ,3825 ,
3826 .errors = &errors,3826 .diagnostics = &diagnostics,
3827 }));3827 }));
38283828
3829 // Test freeing partially allocated slices3829 // Test freeing partially allocated slices
...@@ -3837,7 +3837,7 @@ test "std.zon free on error" {...@@ -3837,7 +3837,7 @@ test "std.zon free on error" {
3837 \\ false,3837 \\ false,
3838 \\}3838 \\}
3839 ,3839 ,
3840 .errors = &errors,3840 .diagnostics = &diagnostics,
3841 }));3841 }));
38423842
3843 // We can parse types that can't be freed, as long as they contain no allocations, e.g. untagged3843 // We can parse types that can't be freed, as long as they contain no allocations, e.g. untagged
...@@ -3848,7 +3848,7 @@ test "std.zon free on error" {...@@ -3848,7 +3848,7 @@ test "std.zon free on error" {
3848 .gpa = gpa,3848 .gpa = gpa,
3849 .arena = arena,3849 .arena = arena,
3850 .source = ".{ .x = 1.5 }",3850 .source = ".{ .x = 1.5 }",
3851 .errors = &errors,3851 .diagnostics = &diagnostics,
3852 })).x,3852 })).x,
3853 );3853 );
38543854
...@@ -3859,7 +3859,7 @@ test "std.zon free on error" {...@@ -3859,7 +3859,7 @@ test "std.zon free on error" {
3859 .gpa = gpa,3859 .gpa = gpa,
3860 .arena = arena,3860 .arena = arena,
3861 .source = ".{ .x = \"foo\" }",3861 .source = ".{ .x = \"foo\" }",
3862 .errors = &errors,3862 .diagnostics = &diagnostics,
3863 });3863 });
3864 try std.testing.expectEqualStrings("foo", result.x);3864 try std.testing.expectEqualStrings("foo", result.x);
3865 }3865 }
...@@ -3873,7 +3873,7 @@ test "std.zon vector" {...@@ -3873,7 +3873,7 @@ test "std.zon vector" {
3873 var arena_allocator: ArenaAllocator = .init(gpa);3873 var arena_allocator: ArenaAllocator = .init(gpa);
3874 defer arena_allocator.deinit();3874 defer arena_allocator.deinit();
3875 const arena = arena_allocator.allocator();3875 const arena = arena_allocator.allocator();
3876 var errors: Errors = .empty;3876 var diagnostics: Diagnostics = .empty;
38773877
3878 // Passing cases3878 // Passing cases
3879 try std.testing.expectEqual(3879 try std.testing.expectEqual(
...@@ -3882,7 +3882,7 @@ test "std.zon vector" {...@@ -3882,7 +3882,7 @@ test "std.zon vector" {
3882 .gpa = gpa,3882 .gpa = gpa,
3883 .arena = arena,3883 .arena = arena,
3884 .source = ".{}",3884 .source = ".{}",
3885 .errors = &errors,3885 .diagnostics = &diagnostics,
3886 }),3886 }),
3887 );3887 );
3888 try std.testing.expectEqual(3888 try std.testing.expectEqual(
...@@ -3891,7 +3891,7 @@ test "std.zon vector" {...@@ -3891,7 +3891,7 @@ test "std.zon vector" {
3891 .gpa = gpa,3891 .gpa = gpa,
3892 .arena = arena,3892 .arena = arena,
3893 .source = ".{true, false, true}",3893 .source = ".{true, false, true}",
3894 .errors = &errors,3894 .diagnostics = &diagnostics,
3895 }),3895 }),
3896 );3896 );
38973897
...@@ -3901,7 +3901,7 @@ test "std.zon vector" {...@@ -3901,7 +3901,7 @@ test "std.zon vector" {
3901 .gpa = gpa,3901 .gpa = gpa,
3902 .arena = arena,3902 .arena = arena,
3903 .source = ".{}",3903 .source = ".{}",
3904 .errors = &errors,3904 .diagnostics = &diagnostics,
3905 }),3905 }),
3906 );3906 );
3907 try std.testing.expectEqual(3907 try std.testing.expectEqual(
...@@ -3910,7 +3910,7 @@ test "std.zon vector" {...@@ -3910,7 +3910,7 @@ test "std.zon vector" {
3910 .gpa = gpa,3910 .gpa = gpa,
3911 .arena = arena,3911 .arena = arena,
3912 .source = ".{1.5, 2.5, 3.5}",3912 .source = ".{1.5, 2.5, 3.5}",
3913 .errors = &errors,3913 .diagnostics = &diagnostics,
3914 }),3914 }),
3915 );3915 );
39163916
...@@ -3920,7 +3920,7 @@ test "std.zon vector" {...@@ -3920,7 +3920,7 @@ test "std.zon vector" {
3920 .gpa = gpa,3920 .gpa = gpa,
3921 .arena = arena,3921 .arena = arena,
3922 .source = ".{}",3922 .source = ".{}",
3923 .errors = &errors,3923 .diagnostics = &diagnostics,
3924 }),3924 }),
3925 );3925 );
3926 try std.testing.expectEqual(3926 try std.testing.expectEqual(
...@@ -3929,7 +3929,7 @@ test "std.zon vector" {...@@ -3929,7 +3929,7 @@ test "std.zon vector" {
3929 .gpa = gpa,3929 .gpa = gpa,
3930 .arena = arena,3930 .arena = arena,
3931 .source = ".{2, 4, 6}",3931 .source = ".{2, 4, 6}",
3932 .errors = &errors,3932 .diagnostics = &diagnostics,
3933 }),3933 }),
3934 );3934 );
39353935
...@@ -3940,14 +3940,14 @@ test "std.zon vector" {...@@ -3940,14 +3940,14 @@ test "std.zon vector" {
3940 .gpa = gpa,3940 .gpa = gpa,
3941 .arena = arena,3941 .arena = arena,
3942 .source = ".{}",3942 .source = ".{}",
3943 .errors = &errors,3943 .diagnostics = &diagnostics,
3944 }),3944 }),
3945 );3945 );
3946 const pointers = try fromSlice(@Vector(3, *const u8), .{3946 const pointers = try fromSlice(@Vector(3, *const u8), .{
3947 .gpa = gpa,3947 .gpa = gpa,
3948 .arena = arena,3948 .arena = arena,
3949 .source = ".{2, 4, 6}",3949 .source = ".{2, 4, 6}",
3950 .errors = &errors,3950 .diagnostics = &diagnostics,
3951 });3951 });
3952 try std.testing.expectEqualDeep(@Vector(3, *const u8){ &2, &4, &6 }, pointers);3952 try std.testing.expectEqualDeep(@Vector(3, *const u8){ &2, &4, &6 }, pointers);
3953 }3953 }
...@@ -3959,14 +3959,14 @@ test "std.zon vector" {...@@ -3959,14 +3959,14 @@ test "std.zon vector" {
3959 .gpa = gpa,3959 .gpa = gpa,
3960 .arena = arena,3960 .arena = arena,
3961 .source = ".{}",3961 .source = ".{}",
3962 .errors = &errors,3962 .diagnostics = &diagnostics,
3963 }),3963 }),
3964 );3964 );
3965 const pointers = try fromSlice(@Vector(3, ?*const u8), .{3965 const pointers = try fromSlice(@Vector(3, ?*const u8), .{
3966 .gpa = gpa,3966 .gpa = gpa,
3967 .arena = arena,3967 .arena = arena,
3968 .source = ".{2, null, 6}",3968 .source = ".{2, null, 6}",
3969 .errors = &errors,3969 .diagnostics = &diagnostics,
3970 });3970 });
3971 try std.testing.expectEqualDeep(@Vector(3, ?*const u8){ &2, null, &6 }, pointers);3971 try std.testing.expectEqualDeep(@Vector(3, ?*const u8){ &2, null, &6 }, pointers);
3972 }3972 }
...@@ -3979,13 +3979,13 @@ test "std.zon vector" {...@@ -3979,13 +3979,13 @@ test "std.zon vector" {
3979 .gpa = gpa,3979 .gpa = gpa,
3980 .arena = arena,3980 .arena = arena,
3981 .source = ".{0.5}",3981 .source = ".{0.5}",
3982 .errors = &errors,3982 .diagnostics = &diagnostics,
3983 }),3983 }),
3984 );3984 );
3985 try std.testing.expectFmt(3985 try std.testing.expectFmt(
3986 \\input.zon:1:2: error: expected 2 array elements; found 13986 \\input.zon:1:2: error: expected 2 array elements; found 1
3987 \\3987 \\
3988 , "{f}", .{errors.fmt("input.zon")});3988 , "{f}", .{diagnostics.fmt("input.zon")});
3989 }3989 }
39903990
3991 // Too many fields3991 // Too many fields
...@@ -3996,13 +3996,13 @@ test "std.zon vector" {...@@ -3996,13 +3996,13 @@ test "std.zon vector" {
3996 .gpa = gpa,3996 .gpa = gpa,
3997 .arena = arena,3997 .arena = arena,
3998 .source = ".{0.5, 1.5, 2.5}",3998 .source = ".{0.5, 1.5, 2.5}",
3999 .errors = &errors,3999 .diagnostics = &diagnostics,
4000 }),4000 }),
4001 );4001 );
4002 try std.testing.expectFmt(4002 try std.testing.expectFmt(
4003 \\input.zon:1:13: error: index 2 outside of array of length 24003 \\input.zon:1:13: error: index 2 outside of array of length 2
4004 \\4004 \\
4005 , "{f}", .{errors.fmt("input.zon")});4005 , "{f}", .{diagnostics.fmt("input.zon")});
4006 }4006 }
40074007
4008 // Wrong type fields4008 // Wrong type fields
...@@ -4013,13 +4013,13 @@ test "std.zon vector" {...@@ -4013,13 +4013,13 @@ test "std.zon vector" {
4013 .gpa = gpa,4013 .gpa = gpa,
4014 .arena = arena,4014 .arena = arena,
4015 .source = ".{0.5, true, 2.5}",4015 .source = ".{0.5, true, 2.5}",
4016 .errors = &errors,4016 .diagnostics = &diagnostics,
4017 }),4017 }),
4018 );4018 );
4019 try std.testing.expectFmt(4019 try std.testing.expectFmt(
4020 \\input.zon:1:8: error: expected type 'f32'4020 \\input.zon:1:8: error: expected type 'f32'
4021 \\4021 \\
4022 , "{f}", .{errors.fmt("input.zon")});4022 , "{f}", .{diagnostics.fmt("input.zon")});
4023 }4023 }
40244024
4025 // Wrong type4025 // Wrong type
...@@ -4030,13 +4030,13 @@ test "std.zon vector" {...@@ -4030,13 +4030,13 @@ test "std.zon vector" {
4030 .gpa = gpa,4030 .gpa = gpa,
4031 .arena = arena,4031 .arena = arena,
4032 .source = "true",4032 .source = "true",
4033 .errors = &errors,4033 .diagnostics = &diagnostics,
4034 }),4034 }),
4035 );4035 );
4036 try std.testing.expectFmt(4036 try std.testing.expectFmt(
4037 \\input.zon:1:1: error: expected type '@Vector(3, u8)'4037 \\input.zon:1:1: error: expected type '@Vector(3, u8)'
4038 \\4038 \\
4039 , "{f}", .{errors.fmt("input.zon")});4039 , "{f}", .{diagnostics.fmt("input.zon")});
4040 }4040 }
40414041
4042 // Elements should get freed on error4042 // Elements should get freed on error
...@@ -4047,13 +4047,13 @@ test "std.zon vector" {...@@ -4047,13 +4047,13 @@ test "std.zon vector" {
4047 .gpa = gpa,4047 .gpa = gpa,
4048 .arena = arena,4048 .arena = arena,
4049 .source = ".{1, true, 3}",4049 .source = ".{1, true, 3}",
4050 .errors = &errors,4050 .diagnostics = &diagnostics,
4051 }),4051 }),
4052 );4052 );
4053 try std.testing.expectFmt(4053 try std.testing.expectFmt(
4054 \\input.zon:1:6: error: expected type 'u8'4054 \\input.zon:1:6: error: expected type 'u8'
4055 \\4055 \\
4056 , "{f}", .{errors.fmt("input.zon")});4056 , "{f}", .{diagnostics.fmt("input.zon")});
4057 }4057 }
4058}4058}
40594059
...@@ -4062,7 +4062,7 @@ test "std.zon add pointers" {...@@ -4062,7 +4062,7 @@ test "std.zon add pointers" {
4062 var arena_allocator: ArenaAllocator = .init(gpa);4062 var arena_allocator: ArenaAllocator = .init(gpa);
4063 defer arena_allocator.deinit();4063 defer arena_allocator.deinit();
4064 const arena = arena_allocator.allocator();4064 const arena = arena_allocator.allocator();
4065 var errors: Errors = .empty;4065 var diagnostics: Diagnostics = .empty;
40664066
4067 // Primitive with varying levels of pointers4067 // Primitive with varying levels of pointers
4068 {4068 {
...@@ -4070,7 +4070,7 @@ test "std.zon add pointers" {...@@ -4070,7 +4070,7 @@ test "std.zon add pointers" {
4070 .gpa = gpa,4070 .gpa = gpa,
4071 .arena = arena,4071 .arena = arena,
4072 .source = "10",4072 .source = "10",
4073 .errors = &errors,4073 .diagnostics = &diagnostics,
4074 });4074 });
4075 try std.testing.expectEqual(@as(u32, 10), result.*);4075 try std.testing.expectEqual(@as(u32, 10), result.*);
4076 }4076 }
...@@ -4080,7 +4080,7 @@ test "std.zon add pointers" {...@@ -4080,7 +4080,7 @@ test "std.zon add pointers" {
4080 .gpa = gpa,4080 .gpa = gpa,
4081 .arena = arena,4081 .arena = arena,
4082 .source = "10",4082 .source = "10",
4083 .errors = &errors,4083 .diagnostics = &diagnostics,
4084 });4084 });
4085 try std.testing.expectEqual(@as(u32, 10), result.*.*);4085 try std.testing.expectEqual(@as(u32, 10), result.*.*);
4086 }4086 }
...@@ -4090,7 +4090,7 @@ test "std.zon add pointers" {...@@ -4090,7 +4090,7 @@ test "std.zon add pointers" {
4090 .gpa = gpa,4090 .gpa = gpa,
4091 .arena = arena,4091 .arena = arena,
4092 .source = "10",4092 .source = "10",
4093 .errors = &errors,4093 .diagnostics = &diagnostics,
4094 });4094 });
4095 try std.testing.expectEqual(@as(u32, 10), result.*.*.*);4095 try std.testing.expectEqual(@as(u32, 10), result.*.*.*);
4096 }4096 }
...@@ -4101,7 +4101,7 @@ test "std.zon add pointers" {...@@ -4101,7 +4101,7 @@ test "std.zon add pointers" {
4101 .gpa = gpa,4101 .gpa = gpa,
4102 .arena = arena,4102 .arena = arena,
4103 .source = "10",4103 .source = "10",
4104 .errors = &errors,4104 .diagnostics = &diagnostics,
4105 });4105 });
4106 try std.testing.expectEqual(@as(u32, 10), some.?.*);4106 try std.testing.expectEqual(@as(u32, 10), some.?.*);
41074107
...@@ -4109,7 +4109,7 @@ test "std.zon add pointers" {...@@ -4109,7 +4109,7 @@ test "std.zon add pointers" {
4109 .gpa = gpa,4109 .gpa = gpa,
4110 .arena = arena,4110 .arena = arena,
4111 .source = "null",4111 .source = "null",
4112 .errors = &errors,4112 .diagnostics = &diagnostics,
4113 });4113 });
4114 try std.testing.expectEqual(null, none);4114 try std.testing.expectEqual(null, none);
4115 }4115 }
...@@ -4119,7 +4119,7 @@ test "std.zon add pointers" {...@@ -4119,7 +4119,7 @@ test "std.zon add pointers" {
4119 .gpa = gpa,4119 .gpa = gpa,
4120 .arena = arena,4120 .arena = arena,
4121 .source = "10",4121 .source = "10",
4122 .errors = &errors,4122 .diagnostics = &diagnostics,
4123 });4123 });
4124 try std.testing.expectEqual(@as(u32, 10), some.*.?);4124 try std.testing.expectEqual(@as(u32, 10), some.*.?);
41254125
...@@ -4127,7 +4127,7 @@ test "std.zon add pointers" {...@@ -4127,7 +4127,7 @@ test "std.zon add pointers" {
4127 .gpa = gpa,4127 .gpa = gpa,
4128 .arena = arena,4128 .arena = arena,
4129 .source = "null",4129 .source = "null",
4130 .errors = &errors,4130 .diagnostics = &diagnostics,
4131 });4131 });
4132 try std.testing.expectEqual(null, none.*);4132 try std.testing.expectEqual(null, none.*);
4133 }4133 }
...@@ -4137,7 +4137,7 @@ test "std.zon add pointers" {...@@ -4137,7 +4137,7 @@ test "std.zon add pointers" {
4137 .gpa = gpa,4137 .gpa = gpa,
4138 .arena = arena,4138 .arena = arena,
4139 .source = "10",4139 .source = "10",
4140 .errors = &errors,4140 .diagnostics = &diagnostics,
4141 });4141 });
4142 try std.testing.expectEqual(@as(u32, 10), some.?.*.*);4142 try std.testing.expectEqual(@as(u32, 10), some.?.*.*);
41434143
...@@ -4145,7 +4145,7 @@ test "std.zon add pointers" {...@@ -4145,7 +4145,7 @@ test "std.zon add pointers" {
4145 .gpa = gpa,4145 .gpa = gpa,
4146 .arena = arena,4146 .arena = arena,
4147 .source = "null",4147 .source = "null",
4148 .errors = &errors,4148 .diagnostics = &diagnostics,
4149 });4149 });
4150 try std.testing.expectEqual(null, none);4150 try std.testing.expectEqual(null, none);
4151 }4151 }
...@@ -4155,7 +4155,7 @@ test "std.zon add pointers" {...@@ -4155,7 +4155,7 @@ test "std.zon add pointers" {
4155 .gpa = gpa,4155 .gpa = gpa,
4156 .arena = arena,4156 .arena = arena,
4157 .source = "10",4157 .source = "10",
4158 .errors = &errors,4158 .diagnostics = &diagnostics,
4159 });4159 });
4160 try std.testing.expectEqual(@as(u32, 10), some.*.?.*);4160 try std.testing.expectEqual(@as(u32, 10), some.*.?.*);
41614161
...@@ -4163,7 +4163,7 @@ test "std.zon add pointers" {...@@ -4163,7 +4163,7 @@ test "std.zon add pointers" {
4163 .gpa = gpa,4163 .gpa = gpa,
4164 .arena = arena,4164 .arena = arena,
4165 .source = "null",4165 .source = "null",
4166 .errors = &errors,4166 .diagnostics = &diagnostics,
4167 });4167 });
4168 try std.testing.expectEqual(null, none.*);4168 try std.testing.expectEqual(null, none.*);
4169 }4169 }
...@@ -4173,7 +4173,7 @@ test "std.zon add pointers" {...@@ -4173,7 +4173,7 @@ test "std.zon add pointers" {
4173 .gpa = gpa,4173 .gpa = gpa,
4174 .arena = arena,4174 .arena = arena,
4175 .source = "10",4175 .source = "10",
4176 .errors = &errors,4176 .diagnostics = &diagnostics,
4177 });4177 });
4178 try std.testing.expectEqual(@as(u32, 10), some.*.*.?);4178 try std.testing.expectEqual(@as(u32, 10), some.*.*.?);
41794179
...@@ -4181,7 +4181,7 @@ test "std.zon add pointers" {...@@ -4181,7 +4181,7 @@ test "std.zon add pointers" {
4181 .gpa = gpa,4181 .gpa = gpa,
4182 .arena = arena,4182 .arena = arena,
4183 .source = "null",4183 .source = "null",
4184 .errors = &errors,4184 .diagnostics = &diagnostics,
4185 });4185 });
4186 try std.testing.expectEqual(null, none.*.*);4186 try std.testing.expectEqual(null, none.*.*);
4187 }4187 }
...@@ -4192,7 +4192,7 @@ test "std.zon add pointers" {...@@ -4192,7 +4192,7 @@ test "std.zon add pointers" {
4192 .gpa = gpa,4192 .gpa = gpa,
4193 .arena = arena,4193 .arena = arena,
4194 .source = ".{ 1, 2, 3 }",4194 .source = ".{ 1, 2, 3 }",
4195 .errors = &errors,4195 .diagnostics = &diagnostics,
4196 });4196 });
4197 try std.testing.expectEqual([3]u8{ 1, 2, 3 }, result.*);4197 try std.testing.expectEqual([3]u8{ 1, 2, 3 }, result.*);
4198 }4198 }
...@@ -4227,7 +4227,7 @@ test "std.zon add pointers" {...@@ -4227,7 +4227,7 @@ test "std.zon add pointers" {
4227 \\ .f2 = null,4227 \\ .f2 = null,
4228 \\}4228 \\}
4229 ,4229 ,
4230 .errors = &errors,4230 .diagnostics = &diagnostics,
4231 });4231 });
42324232
4233 try std.testing.expectEqualDeep(expected, found.?.*);4233 try std.testing.expectEqualDeep(expected, found.?.*);
...@@ -4241,13 +4241,13 @@ test "std.zon add pointers" {...@@ -4241,13 +4241,13 @@ test "std.zon add pointers" {
4241 .gpa = gpa,4241 .gpa = gpa,
4242 .arena = arena,4242 .arena = arena,
4243 .source = "true",4243 .source = "true",
4244 .errors = &errors,4244 .diagnostics = &diagnostics,
4245 }),4245 }),
4246 );4246 );
4247 try std.testing.expectFmt(4247 try std.testing.expectFmt(
4248 \\input.zon:1:1: error: expected type '?u8'4248 \\input.zon:1:1: error: expected type '?u8'
4249 \\4249 \\
4250 , "{f}", .{errors.fmt("input.zon")});4250 , "{f}", .{diagnostics.fmt("input.zon")});
4251 }4251 }
42524252
4253 {4253 {
...@@ -4257,13 +4257,13 @@ test "std.zon add pointers" {...@@ -4257,13 +4257,13 @@ test "std.zon add pointers" {
4257 .gpa = gpa,4257 .gpa = gpa,
4258 .arena = arena,4258 .arena = arena,
4259 .source = "true",4259 .source = "true",
4260 .errors = &errors,4260 .diagnostics = &diagnostics,
4261 }),4261 }),
4262 );4262 );
4263 try std.testing.expectFmt(4263 try std.testing.expectFmt(
4264 \\input.zon:1:1: error: expected type '?f32'4264 \\input.zon:1:1: error: expected type '?f32'
4265 \\4265 \\
4266 , "{f}", .{errors.fmt("input.zon")});4266 , "{f}", .{diagnostics.fmt("input.zon")});
4267 }4267 }
42684268
4269 {4269 {
...@@ -4273,13 +4273,13 @@ test "std.zon add pointers" {...@@ -4273,13 +4273,13 @@ test "std.zon add pointers" {
4273 .gpa = gpa,4273 .gpa = gpa,
4274 .arena = arena,4274 .arena = arena,
4275 .source = "true",4275 .source = "true",
4276 .errors = &errors,4276 .diagnostics = &diagnostics,
4277 }),4277 }),
4278 );4278 );
4279 try std.testing.expectFmt(4279 try std.testing.expectFmt(
4280 \\input.zon:1:1: error: expected type '?@Vector(3, u8)'4280 \\input.zon:1:1: error: expected type '?@Vector(3, u8)'
4281 \\4281 \\
4282 , "{f}", .{errors.fmt("input.zon")});4282 , "{f}", .{diagnostics.fmt("input.zon")});
4283 }4283 }
42844284
4285 {4285 {
...@@ -4289,13 +4289,13 @@ test "std.zon add pointers" {...@@ -4289,13 +4289,13 @@ test "std.zon add pointers" {
4289 .gpa = gpa,4289 .gpa = gpa,
4290 .arena = arena,4290 .arena = arena,
4291 .source = "10",4291 .source = "10",
4292 .errors = &errors,4292 .diagnostics = &diagnostics,
4293 }),4293 }),
4294 );4294 );
4295 try std.testing.expectFmt(4295 try std.testing.expectFmt(
4296 \\input.zon:1:1: error: expected type '?bool'4296 \\input.zon:1:1: error: expected type '?bool'
4297 \\4297 \\
4298 , "{f}", .{errors.fmt("input.zon")});4298 , "{f}", .{diagnostics.fmt("input.zon")});
4299 }4299 }
43004300
4301 {4301 {
...@@ -4305,13 +4305,13 @@ test "std.zon add pointers" {...@@ -4305,13 +4305,13 @@ test "std.zon add pointers" {
4305 .gpa = gpa,4305 .gpa = gpa,
4306 .arena = arena,4306 .arena = arena,
4307 .source = "true",4307 .source = "true",
4308 .errors = &errors,4308 .diagnostics = &diagnostics,
4309 }),4309 }),
4310 );4310 );
4311 try std.testing.expectFmt(4311 try std.testing.expectFmt(
4312 \\input.zon:1:1: error: expected optional struct4312 \\input.zon:1:1: error: expected optional struct
4313 \\4313 \\
4314 , "{f}", .{errors.fmt("input.zon")});4314 , "{f}", .{diagnostics.fmt("input.zon")});
4315 }4315 }
43164316
4317 {4317 {
...@@ -4321,13 +4321,13 @@ test "std.zon add pointers" {...@@ -4321,13 +4321,13 @@ test "std.zon add pointers" {
4321 .gpa = gpa,4321 .gpa = gpa,
4322 .arena = arena,4322 .arena = arena,
4323 .source = "true",4323 .source = "true",
4324 .errors = &errors,4324 .diagnostics = &diagnostics,
4325 }),4325 }),
4326 );4326 );
4327 try std.testing.expectFmt(4327 try std.testing.expectFmt(
4328 \\input.zon:1:1: error: expected optional tuple4328 \\input.zon:1:1: error: expected optional tuple
4329 \\4329 \\
4330 , "{f}", .{errors.fmt("input.zon")});4330 , "{f}", .{diagnostics.fmt("input.zon")});
4331 }4331 }
43324332
4333 {4333 {
...@@ -4337,13 +4337,13 @@ test "std.zon add pointers" {...@@ -4337,13 +4337,13 @@ test "std.zon add pointers" {
4337 .gpa = gpa,4337 .gpa = gpa,
4338 .arena = arena,4338 .arena = arena,
4339 .source = "true",4339 .source = "true",
4340 .errors = &errors,4340 .diagnostics = &diagnostics,
4341 }),4341 }),
4342 );4342 );
4343 try std.testing.expectFmt(4343 try std.testing.expectFmt(
4344 \\input.zon:1:1: error: expected optional union4344 \\input.zon:1:1: error: expected optional union
4345 \\4345 \\
4346 , "{f}", .{errors.fmt("input.zon")});4346 , "{f}", .{diagnostics.fmt("input.zon")});
4347 }4347 }
43484348
4349 {4349 {
...@@ -4353,13 +4353,13 @@ test "std.zon add pointers" {...@@ -4353,13 +4353,13 @@ test "std.zon add pointers" {
4353 .gpa = gpa,4353 .gpa = gpa,
4354 .arena = arena,4354 .arena = arena,
4355 .source = "true",4355 .source = "true",
4356 .errors = &errors,4356 .diagnostics = &diagnostics,
4357 }),4357 }),
4358 );4358 );
4359 try std.testing.expectFmt(4359 try std.testing.expectFmt(
4360 \\input.zon:1:1: error: expected optional array4360 \\input.zon:1:1: error: expected optional array
4361 \\4361 \\
4362 , "{f}", .{errors.fmt("input.zon")});4362 , "{f}", .{diagnostics.fmt("input.zon")});
4363 }4363 }
43644364
4365 {4365 {
...@@ -4369,13 +4369,13 @@ test "std.zon add pointers" {...@@ -4369,13 +4369,13 @@ test "std.zon add pointers" {
4369 .gpa = gpa,4369 .gpa = gpa,
4370 .arena = arena,4370 .arena = arena,
4371 .source = "true",4371 .source = "true",
4372 .errors = &errors,4372 .diagnostics = &diagnostics,
4373 }),4373 }),
4374 );4374 );
4375 try std.testing.expectFmt(4375 try std.testing.expectFmt(
4376 \\input.zon:1:1: error: expected optional array4376 \\input.zon:1:1: error: expected optional array
4377 \\4377 \\
4378 , "{f}", .{errors.fmt("input.zon")});4378 , "{f}", .{diagnostics.fmt("input.zon")});
4379 }4379 }
43804380
4381 {4381 {
...@@ -4385,13 +4385,13 @@ test "std.zon add pointers" {...@@ -4385,13 +4385,13 @@ test "std.zon add pointers" {
4385 .gpa = gpa,4385 .gpa = gpa,
4386 .arena = arena,4386 .arena = arena,
4387 .source = "true",4387 .source = "true",
4388 .errors = &errors,4388 .diagnostics = &diagnostics,
4389 }),4389 }),
4390 );4390 );
4391 try std.testing.expectFmt(4391 try std.testing.expectFmt(
4392 \\input.zon:1:1: error: expected optional array4392 \\input.zon:1:1: error: expected optional array
4393 \\4393 \\
4394 , "{f}", .{errors.fmt("input.zon")});4394 , "{f}", .{diagnostics.fmt("input.zon")});
4395 }4395 }
43964396
4397 {4397 {
...@@ -4401,13 +4401,13 @@ test "std.zon add pointers" {...@@ -4401,13 +4401,13 @@ test "std.zon add pointers" {
4401 .gpa = gpa,4401 .gpa = gpa,
4402 .arena = arena,4402 .arena = arena,
4403 .source = "true",4403 .source = "true",
4404 .errors = &errors,4404 .diagnostics = &diagnostics,
4405 }),4405 }),
4406 );4406 );
4407 try std.testing.expectFmt(4407 try std.testing.expectFmt(
4408 \\input.zon:1:1: error: expected optional array4408 \\input.zon:1:1: error: expected optional array
4409 \\4409 \\
4410 , "{f}", .{errors.fmt("input.zon")});4410 , "{f}", .{diagnostics.fmt("input.zon")});
4411 }4411 }
44124412
4413 {4413 {
...@@ -4417,13 +4417,13 @@ test "std.zon add pointers" {...@@ -4417,13 +4417,13 @@ test "std.zon add pointers" {
4417 .gpa = gpa,4417 .gpa = gpa,
4418 .arena = arena,4418 .arena = arena,
4419 .source = "true",4419 .source = "true",
4420 .errors = &errors,4420 .diagnostics = &diagnostics,
4421 }),4421 }),
4422 );4422 );
4423 try std.testing.expectFmt(4423 try std.testing.expectFmt(
4424 \\input.zon:1:1: error: expected optional string4424 \\input.zon:1:1: error: expected optional string
4425 \\4425 \\
4426 , "{f}", .{errors.fmt("input.zon")});4426 , "{f}", .{diagnostics.fmt("input.zon")});
4427 }4427 }
44284428
4429 {4429 {
...@@ -4433,13 +4433,13 @@ test "std.zon add pointers" {...@@ -4433,13 +4433,13 @@ test "std.zon add pointers" {
4433 .gpa = gpa,4433 .gpa = gpa,
4434 .arena = arena,4434 .arena = arena,
4435 .source = "true",4435 .source = "true",
4436 .errors = &errors,4436 .diagnostics = &diagnostics,
4437 }),4437 }),
4438 );4438 );
4439 try std.testing.expectFmt(4439 try std.testing.expectFmt(
4440 \\input.zon:1:1: error: expected optional enum literal4440 \\input.zon:1:1: error: expected optional enum literal
4441 \\4441 \\
4442 , "{f}", .{errors.fmt("input.zon")});4442 , "{f}", .{diagnostics.fmt("input.zon")});
4443 }4443 }
4444}4444}
44454445
...@@ -4448,7 +4448,7 @@ test "std.zon stop on node" {...@@ -4448,7 +4448,7 @@ test "std.zon stop on node" {
4448 var arena_allocator: ArenaAllocator = .init(gpa);4448 var arena_allocator: ArenaAllocator = .init(gpa);
4449 defer arena_allocator.deinit();4449 defer arena_allocator.deinit();
4450 const arena = arena_allocator.allocator();4450 const arena = arena_allocator.allocator();
4451 var errors: Errors = .empty;4451 var diagnostics: Diagnostics = .empty;
44524452
4453 {4453 {
4454 const Vec2 = struct {4454 const Vec2 = struct {
...@@ -4466,7 +4466,7 @@ test "std.zon stop on node" {...@@ -4466,7 +4466,7 @@ test "std.zon stop on node" {
4466 .arena = arena,4466 .arena = arena,
4467 .ast = &ast,4467 .ast = &ast,
4468 .zoir = &zoir,4468 .zoir = &zoir,
4469 .errors = &errors,4469 .diagnostics = &diagnostics,
4470 });4470 });
44714471
4472 try std.testing.expectEqual(result.y, 2.5);4472 try std.testing.expectEqual(result.y, 2.5);
...@@ -4484,7 +4484,7 @@ test "std.zon stop on node" {...@@ -4484,7 +4484,7 @@ test "std.zon stop on node" {
4484 .arena = arena,4484 .arena = arena,
4485 .ast = &ast,4485 .ast = &ast,
4486 .zoir = &zoir,4486 .zoir = &zoir,
4487 .errors = &errors,4487 .diagnostics = &diagnostics,
4488 });4488 });
4489 try std.testing.expectEqual(Zoir.Node{ .float_literal = 1.23 }, result.get(&zoir));4489 try std.testing.expectEqual(Zoir.Node{ .float_literal = 1.23 }, result.get(&zoir));
4490 }4490 }
...@@ -4495,7 +4495,7 @@ test "std.zon no alloc" {...@@ -4495,7 +4495,7 @@ test "std.zon no alloc" {
4495 var arena_allocator: ArenaAllocator = .init(gpa);4495 var arena_allocator: ArenaAllocator = .init(gpa);
4496 defer arena_allocator.deinit();4496 defer arena_allocator.deinit();
4497 const arena = arena_allocator.allocator();4497 const arena = arena_allocator.allocator();
4498 var errors: Errors = .empty;4498 var diagnostics: Diagnostics = .empty;
44994499
4500 try std.testing.expectEqual(4500 try std.testing.expectEqual(
4501 [3]u8{ 1, 2, 3 },4501 [3]u8{ 1, 2, 3 },
...@@ -4503,7 +4503,7 @@ test "std.zon no alloc" {...@@ -4503,7 +4503,7 @@ test "std.zon no alloc" {
4503 .gpa = gpa,4503 .gpa = gpa,
4504 .arena = arena,4504 .arena = arena,
4505 .source = ".{ 1, 2, 3 }",4505 .source = ".{ 1, 2, 3 }",
4506 .errors = &errors,4506 .diagnostics = &diagnostics,
4507 }),4507 }),
4508 );4508 );
45094509
...@@ -4521,64 +4521,17 @@ test "std.zon no alloc" {...@@ -4521,64 +4521,17 @@ test "std.zon no alloc" {
4521 .arena = arena,4521 .arena = arena,
4522 .ast = &ast,4522 .ast = &ast,
4523 .zoir = &zoir,4523 .zoir = &zoir,
4524 .errors = &errors,4524 .diagnostics = &diagnostics,
4525 }),4525 }),
4526 );4526 );
4527}4527}
45284528
4529test "std.zon errors without errorsnostics" {
4530 const gpa = std.testing.allocator;
4531 var arena_allocator: ArenaAllocator = .init(gpa);
4532 defer arena_allocator.deinit();
4533 const arena = arena_allocator.allocator();
4534 var errors: Errors = .empty;
4535
4536 const Enum = enum {
4537 foo,
4538 bar,
4539 baz,
4540 };
4541 try std.testing.expectError(error.ParseZon, fromSlice(Enum, .{
4542 .gpa = gpa,
4543 .arena = arena,
4544 .source = ".nothing",
4545 .errors = &errors,
4546 }));
4547
4548 const Struct = struct {
4549 name: []const u8,
4550 };
4551 try std.testing.expectError(error.ParseZon, fromSlice(Struct, .{
4552 .gpa = gpa,
4553 .arena = arena,
4554 .source = ".{ .name = \"Alice\", .age = 25 }",
4555 .errors = &errors,
4556 }));
4557
4558 const Union = union(enum) {
4559 x,
4560 y: u32,
4561 };
4562 try std.testing.expectError(error.ParseZon, fromSlice(Union, .{
4563 .gpa = gpa,
4564 .arena = arena,
4565 .source = ".a",
4566 .errors = &errors,
4567 }));
4568 try std.testing.expectError(error.ParseZon, fromSlice(Union, .{
4569 .gpa = gpa,
4570 .arena = arena,
4571 .source = ".{ .b = 8 }",
4572 .errors = &errors,
4573 }));
4574}
4575
4576test "std.zon aligned pointers" {4529test "std.zon aligned pointers" {
4577 const gpa = std.testing.allocator;4530 const gpa = std.testing.allocator;
4578 var arena_allocator: ArenaAllocator = .init(gpa);4531 var arena_allocator: ArenaAllocator = .init(gpa);
4579 defer arena_allocator.deinit();4532 defer arena_allocator.deinit();
4580 const arena = arena_allocator.allocator();4533 const arena = arena_allocator.allocator();
4581 var errors: Errors = .empty;4534 var diagnostics: Diagnostics = .empty;
45824535
4583 const n: u8 align(8) = 10;4536 const n: u8 align(8) = 10;
4584 const Foo = struct {4537 const Foo = struct {
...@@ -4592,7 +4545,7 @@ test "std.zon aligned pointers" {...@@ -4592,7 +4545,7 @@ test "std.zon aligned pointers" {
4592 .gpa = gpa,4545 .gpa = gpa,
4593 .arena = arena,4546 .arena = arena,
4594 .source = ".{ .inner = 10 }",4547 .source = ".{ .inner = 10 }",
4595 .errors = &errors,4548 .diagnostics = &diagnostics,
4596 });4549 });
4597 try std.testing.expectEqualDeep(expected.inner, found.inner);4550 try std.testing.expectEqualDeep(expected.inner, found.inner);
4598}4551}
...@@ -4602,7 +4555,7 @@ test "std.zon update basic" {...@@ -4602,7 +4555,7 @@ test "std.zon update basic" {
4602 var arena_allocator: ArenaAllocator = .init(gpa);4555 var arena_allocator: ArenaAllocator = .init(gpa);
4603 defer arena_allocator.deinit();4556 defer arena_allocator.deinit();
4604 const arena = arena_allocator.allocator();4557 const arena = arena_allocator.allocator();
4605 var errors: Errors = .empty;4558 var diagnostics: Diagnostics = .empty;
46064559
4607 const Vector = struct { x: f32, y: f32, z: f32 };4560 const Vector = struct { x: f32, y: f32, z: f32 };
4608 const MyStruct = struct {4561 const MyStruct = struct {
...@@ -4638,7 +4591,7 @@ test "std.zon update basic" {...@@ -4638,7 +4591,7 @@ test "std.zon update basic" {
4638 .gpa = gpa,4591 .gpa = gpa,
4639 .arena = arena,4592 .arena = arena,
4640 .source = ".{}",4593 .source = ".{}",
4641 .errors = &errors,4594 .diagnostics = &diagnostics,
4642 });4595 });
4643 try std.testing.expectEqualDeep(expected, found);4596 try std.testing.expectEqualDeep(expected, found);
46444597
...@@ -4646,7 +4599,7 @@ test "std.zon update basic" {...@@ -4646,7 +4599,7 @@ test "std.zon update basic" {
4646 .gpa = gpa,4599 .gpa = gpa,
4647 .arena = arena,4600 .arena = arena,
4648 .source = ".{ .bar = false }",4601 .source = ".{ .bar = false }",
4649 .errors = &errors,4602 .diagnostics = &diagnostics,
4650 });4603 });
4651 expected.bar = false;4604 expected.bar = false;
4652 try std.testing.expectEqualDeep(expected, found);4605 try std.testing.expectEqualDeep(expected, found);
...@@ -4655,7 +4608,7 @@ test "std.zon update basic" {...@@ -4655,7 +4608,7 @@ test "std.zon update basic" {
4655 .gpa = gpa,4608 .gpa = gpa,
4656 .arena = arena,4609 .arena = arena,
4657 .source = ".{ .baz = .{ .a = .{ 2, 4 } } }",4610 .source = ".{ .baz = .{ .a = .{ 2, 4 } } }",
4658 .errors = &errors,4611 .diagnostics = &diagnostics,
4659 });4612 });
4660 expected.baz.a[0] = 2;4613 expected.baz.a[0] = 2;
4661 expected.baz.a[1] = 4;4614 expected.baz.a[1] = 4;
...@@ -4665,7 +4618,7 @@ test "std.zon update basic" {...@@ -4665,7 +4618,7 @@ test "std.zon update basic" {
4665 .gpa = gpa,4618 .gpa = gpa,
4666 .arena = arena,4619 .arena = arena,
4667 .source = ".{ .foo = 11, .baz = .{ .b = .d } }",4620 .source = ".{ .foo = 11, .baz = .{ .b = .d } }",
4668 .errors = &errors,4621 .diagnostics = &diagnostics,
4669 });4622 });
4670 expected.foo = 11;4623 expected.foo = 11;
4671 expected.baz.b = .d;4624 expected.baz.b = .d;
...@@ -4675,7 +4628,7 @@ test "std.zon update basic" {...@@ -4675,7 +4628,7 @@ test "std.zon update basic" {
4675 .gpa = gpa,4628 .gpa = gpa,
4676 .arena = arena,4629 .arena = arena,
4677 .source = ".{ .optional = 10 }",4630 .source = ".{ .optional = 10 }",
4678 .errors = &errors,4631 .diagnostics = &diagnostics,
4679 });4632 });
4680 expected.optional = 10;4633 expected.optional = 10;
4681 try std.testing.expectEqualDeep(expected, found);4634 try std.testing.expectEqualDeep(expected, found);
...@@ -4684,7 +4637,7 @@ test "std.zon update basic" {...@@ -4684,7 +4637,7 @@ test "std.zon update basic" {
4684 .gpa = gpa,4637 .gpa = gpa,
4685 .arena = arena,4638 .arena = arena,
4686 .source = ".{ .optional = null }",4639 .source = ".{ .optional = null }",
4687 .errors = &errors,4640 .diagnostics = &diagnostics,
4688 });4641 });
4689 expected.optional = null;4642 expected.optional = null;
4690 try std.testing.expectEqualDeep(expected, found);4643 try std.testing.expectEqualDeep(expected, found);
...@@ -4693,7 +4646,7 @@ test "std.zon update basic" {...@@ -4693,7 +4646,7 @@ test "std.zon update basic" {
4693 .gpa = gpa,4646 .gpa = gpa,
4694 .arena = arena,4647 .arena = arena,
4695 .source = ".{ .ptr = .{ .x = 10, .y = 20, .z = 30 } }",4648 .source = ".{ .ptr = .{ .x = 10, .y = 20, .z = 30 } }",
4696 .errors = &errors,4649 .diagnostics = &diagnostics,
4697 });4650 });
4698 expected.ptr.x = 10;4651 expected.ptr.x = 10;
4699 expected.ptr.y = 20;4652 expected.ptr.y = 20;
...@@ -4704,7 +4657,7 @@ test "std.zon update basic" {...@@ -4704,7 +4657,7 @@ test "std.zon update basic" {
4704 .gpa = gpa,4657 .gpa = gpa,
4705 .arena = arena,4658 .arena = arena,
4706 .source = ".{ .str = \"foo\" }",4659 .source = ".{ .str = \"foo\" }",
4707 .errors = &errors,4660 .diagnostics = &diagnostics,
4708 });4661 });
4709 expected.str = "foo";4662 expected.str = "foo";
4710 try std.testing.expectEqualDeep(expected, found);4663 try std.testing.expectEqualDeep(expected, found);
...@@ -4715,7 +4668,7 @@ test "std.zon update optionals" {...@@ -4715,7 +4668,7 @@ test "std.zon update optionals" {
4715 var arena_allocator: ArenaAllocator = .init(gpa);4668 var arena_allocator: ArenaAllocator = .init(gpa);
4716 defer arena_allocator.deinit();4669 defer arena_allocator.deinit();
4717 const arena = arena_allocator.allocator();4670 const arena = arena_allocator.allocator();
4718 var errors: Errors = .empty;4671 var diagnostics: Diagnostics = .empty;
47194672
4720 const MyStruct = struct {4673 const MyStruct = struct {
4721 foo: ?struct { bar: u32 = 1, baz: u32 = 2, qux: u32 },4674 foo: ?struct { bar: u32 = 1, baz: u32 = 2, qux: u32 },
...@@ -4729,7 +4682,7 @@ test "std.zon update optionals" {...@@ -4729,7 +4682,7 @@ test "std.zon update optionals" {
4729 .gpa = gpa,4682 .gpa = gpa,
4730 .arena = arena,4683 .arena = arena,
4731 .source = ".{ .foo = .{ .qux = 3 } }",4684 .source = ".{ .foo = .{ .qux = 3 } }",
4732 .errors = &errors,4685 .diagnostics = &diagnostics,
4733 });4686 });
4734 expected.foo = .{ .qux = 3 };4687 expected.foo = .{ .qux = 3 };
4735 try std.testing.expectEqual(expected, found);4688 try std.testing.expectEqual(expected, found);
...@@ -4742,12 +4695,12 @@ test "std.zon update optionals" {...@@ -4742,12 +4695,12 @@ test "std.zon update optionals" {
4742 .gpa = gpa,4695 .gpa = gpa,
4743 .arena = arena,4696 .arena = arena,
4744 .source = ".{ .foo = .{} }",4697 .source = ".{ .foo = .{} }",
4745 .errors = &errors,4698 .diagnostics = &diagnostics,
4746 }));4699 }));
4747 try std.testing.expectFmt(4700 try std.testing.expectFmt(
4748 \\input.zon:1:12: error: missing required field qux4701 \\input.zon:1:12: error: missing required field qux
4749 \\4702 \\
4750 , "{f}", .{errors.fmt("input.zon")});4703 , "{f}", .{diagnostics.fmt("input.zon")});
4751 }4704 }
47524705
4753 // Updating an optional that starts out non-null should preserve any values we leave off. It's4706 // Updating an optional that starts out non-null should preserve any values we leave off. It's
...@@ -4761,7 +4714,7 @@ test "std.zon update optionals" {...@@ -4761,7 +4714,7 @@ test "std.zon update optionals" {
4761 .gpa = gpa,4714 .gpa = gpa,
4762 .arena = arena,4715 .arena = arena,
4763 .source = ".{ .foo = .{ .baz = 200 } }",4716 .source = ".{ .foo = .{ .baz = 200 } }",
4764 .errors = &errors,4717 .diagnostics = &diagnostics,
4765 });4718 });
4766 expected.foo.?.baz = 200;4719 expected.foo.?.baz = 200;
4767 try std.testing.expectEqual(expected, found);4720 try std.testing.expectEqual(expected, found);
...@@ -4773,7 +4726,7 @@ test "std.zon update optional pointers" {...@@ -4773,7 +4726,7 @@ test "std.zon update optional pointers" {
4773 var arena_allocator: ArenaAllocator = .init(gpa);4726 var arena_allocator: ArenaAllocator = .init(gpa);
4774 defer arena_allocator.deinit();4727 defer arena_allocator.deinit();
4775 const arena = arena_allocator.allocator();4728 const arena = arena_allocator.allocator();
4776 var errors: Errors = .empty;4729 var diagnostics: Diagnostics = .empty;
47774730
4778 const MyStruct = struct {4731 const MyStruct = struct {
4779 foo: ?*const struct { bar: u32 = 1, baz: u32 = 2, qux: u32 },4732 foo: ?*const struct { bar: u32 = 1, baz: u32 = 2, qux: u32 },
...@@ -4787,7 +4740,7 @@ test "std.zon update optional pointers" {...@@ -4787,7 +4740,7 @@ test "std.zon update optional pointers" {
4787 .gpa = gpa,4740 .gpa = gpa,
4788 .arena = arena,4741 .arena = arena,
4789 .source = ".{ .foo = .{ .qux = 3 } }",4742 .source = ".{ .foo = .{ .qux = 3 } }",
4790 .errors = &errors,4743 .diagnostics = &diagnostics,
4791 });4744 });
4792 expected.foo = &.{ .qux = 3 };4745 expected.foo = &.{ .qux = 3 };
4793 try std.testing.expectEqualDeep(expected, found);4746 try std.testing.expectEqualDeep(expected, found);
...@@ -4799,7 +4752,7 @@ test "std.zon update pointers" {...@@ -4799,7 +4752,7 @@ test "std.zon update pointers" {
4799 var arena_allocator: ArenaAllocator = .init(gpa);4752 var arena_allocator: ArenaAllocator = .init(gpa);
4800 defer arena_allocator.deinit();4753 defer arena_allocator.deinit();
4801 const arena = arena_allocator.allocator();4754 const arena = arena_allocator.allocator();
4802 var errors: Errors = .empty;4755 var diagnostics: Diagnostics = .empty;
48034756
4804 // Updating a pointer should leave fields we don't specify unchanged4757 // Updating a pointer should leave fields we don't specify unchanged
4805 {4758 {
...@@ -4813,7 +4766,7 @@ test "std.zon update pointers" {...@@ -4813,7 +4766,7 @@ test "std.zon update pointers" {
4813 .gpa = gpa,4766 .gpa = gpa,
4814 .arena = arena,4767 .arena = arena,
4815 .source = ".{ .foo = .{ .bar = 100 } }",4768 .source = ".{ .foo = .{ .bar = 100 } }",
4816 .errors = &errors,4769 .diagnostics = &diagnostics,
4817 });4770 });
4818 expected.foo.bar = 100;4771 expected.foo.bar = 100;
4819 try std.testing.expectEqualDeep(expected, found);4772 try std.testing.expectEqualDeep(expected, found);
...@@ -4830,7 +4783,7 @@ test "std.zon update pointers" {...@@ -4830,7 +4783,7 @@ test "std.zon update pointers" {
4830 .gpa = gpa,4783 .gpa = gpa,
4831 .arena = arena,4784 .arena = arena,
4832 .source = ".{ .foo = .{ .bar = 100 } }",4785 .source = ".{ .foo = .{ .bar = 100 } }",
4833 .errors = &errors,4786 .diagnostics = &diagnostics,
4834 });4787 });
4835 expected.foo = &.{ .bar = 100, .baz = 20, .qux = 3 };4788 expected.foo = &.{ .bar = 100, .baz = 20, .qux = 3 };
4836 try std.testing.expectEqualDeep(expected, found);4789 try std.testing.expectEqualDeep(expected, found);
...@@ -4842,7 +4795,7 @@ test "std.zon update unions" {...@@ -4842,7 +4795,7 @@ test "std.zon update unions" {
4842 var arena_allocator: ArenaAllocator = .init(gpa);4795 var arena_allocator: ArenaAllocator = .init(gpa);
4843 defer arena_allocator.deinit();4796 defer arena_allocator.deinit();
4844 const arena = arena_allocator.allocator();4797 const arena = arena_allocator.allocator();
4845 var errors: Errors = .empty;4798 var diagnostics: Diagnostics = .empty;
48464799
4847 const MyUnion = union(enum) {4800 const MyUnion = union(enum) {
4848 none: void,4801 none: void,
...@@ -4857,7 +4810,7 @@ test "std.zon update unions" {...@@ -4857,7 +4810,7 @@ test "std.zon update unions" {
4857 .gpa = gpa,4810 .gpa = gpa,
4858 .arena = arena,4811 .arena = arena,
4859 .source = ".{ .foo = .{ .qux = 3 } }",4812 .source = ".{ .foo = .{ .qux = 3 } }",
4860 .errors = &errors,4813 .diagnostics = &diagnostics,
4861 });4814 });
4862 expected = .{ .foo = .{ .qux = 3 } };4815 expected = .{ .foo = .{ .qux = 3 } };
4863 try std.testing.expectEqual(expected, found);4816 try std.testing.expectEqual(expected, found);
...@@ -4870,12 +4823,12 @@ test "std.zon update unions" {...@@ -4870,12 +4823,12 @@ test "std.zon update unions" {
4870 .gpa = gpa,4823 .gpa = gpa,
4871 .arena = arena,4824 .arena = arena,
4872 .source = ".{ .foo = .{} }",4825 .source = ".{ .foo = .{} }",
4873 .errors = &errors,4826 .diagnostics = &diagnostics,
4874 }));4827 }));
4875 try std.testing.expectFmt(4828 try std.testing.expectFmt(
4876 \\input.zon:1:12: error: missing required field qux4829 \\input.zon:1:12: error: missing required field qux
4877 \\4830 \\
4878 , "{f}", .{errors.fmt("input.zon")});4831 , "{f}", .{diagnostics.fmt("input.zon")});
4879 }4832 }
48804833
4881 // Updating a union should preseve any sub-fields that we left off. It's also okay to leave off4834 // Updating a union should preseve any sub-fields that we left off. It's also okay to leave off
...@@ -4889,7 +4842,7 @@ test "std.zon update unions" {...@@ -4889,7 +4842,7 @@ test "std.zon update unions" {
4889 .gpa = gpa,4842 .gpa = gpa,
4890 .arena = arena,4843 .arena = arena,
4891 .source = ".{ .foo = .{ .baz = 200 } }",4844 .source = ".{ .foo = .{ .baz = 200 } }",
4892 .errors = &errors,4845 .diagnostics = &diagnostics,
4893 });4846 });
4894 expected.foo.baz = 200;4847 expected.foo.baz = 200;
4895 try std.testing.expectEqual(expected, found);4848 try std.testing.expectEqual(expected, found);
...@@ -4904,7 +4857,7 @@ test "std.zon variants" {...@@ -4904,7 +4857,7 @@ test "std.zon variants" {
4904 var arena_allocator: ArenaAllocator = .init(gpa);4857 var arena_allocator: ArenaAllocator = .init(gpa);
4905 defer arena_allocator.deinit();4858 defer arena_allocator.deinit();
4906 const arena = arena_allocator.allocator();4859 const arena = arena_allocator.allocator();
4907 var errors: Errors = .empty;4860 var diagnostics: Diagnostics = .empty;
49084861
4909 const Struct = struct { a: u32, b: u32 };4862 const Struct = struct { a: u32, b: u32 };
4910 const start: Struct = .{ .a = 10, .b = 20 };4863 const start: Struct = .{ .a = 10, .b = 20 };
...@@ -4922,7 +4875,7 @@ test "std.zon variants" {...@@ -4922,7 +4875,7 @@ test "std.zon variants" {
4922 .gpa = gpa,4875 .gpa = gpa,
4923 .arena = arena,4876 .arena = arena,
4924 .source = ".{ .a = 100 }",4877 .source = ".{ .a = 100 }",
4925 .errors = &errors,4878 .diagnostics = &diagnostics,
4926 });4879 });
4927 try std.testing.expectEqual(end, curr);4880 try std.testing.expectEqual(end, curr);
49284881
...@@ -4931,7 +4884,7 @@ test "std.zon variants" {...@@ -4931,7 +4884,7 @@ test "std.zon variants" {
4931 .gpa = gpa,4884 .gpa = gpa,
4932 .arena = arena,4885 .arena = arena,
4933 .source = ".{ .a = 100 }",4886 .source = ".{ .a = 100 }",
4934 .errors = &errors,4887 .diagnostics = &diagnostics,
4935 });4888 });
4936 try std.testing.expectEqual(end, curr);4889 try std.testing.expectEqual(end, curr);
49374890
...@@ -4940,7 +4893,7 @@ test "std.zon variants" {...@@ -4940,7 +4893,7 @@ test "std.zon variants" {
4940 .arena = arena,4893 .arena = arena,
4941 .ast = &ast,4894 .ast = &ast,
4942 .zoir = &zoir,4895 .zoir = &zoir,
4943 .errors = &errors,4896 .diagnostics = &diagnostics,
4944 });4897 });
4945 try std.testing.expectEqual(end, curr);4898 try std.testing.expectEqual(end, curr);
49464899
...@@ -4949,7 +4902,7 @@ test "std.zon variants" {...@@ -4949,7 +4902,7 @@ test "std.zon variants" {
4949 .arena = arena,4902 .arena = arena,
4950 .ast = &ast,4903 .ast = &ast,
4951 .zoir = &zoir,4904 .zoir = &zoir,
4952 .errors = &errors,4905 .diagnostics = &diagnostics,
4953 });4906 });
4954 try std.testing.expectEqual(end, curr);4907 try std.testing.expectEqual(end, curr);
4955 }4908 }
...@@ -4967,7 +4920,7 @@ test "std.zon variants" {...@@ -4967,7 +4920,7 @@ test "std.zon variants" {
4967 .gpa = gpa,4920 .gpa = gpa,
4968 .arena = arena,4921 .arena = arena,
4969 .source = ".{ .a = 100, .b = 20 }",4922 .source = ".{ .a = 100, .b = 20 }",
4970 .errors = &errors,4923 .diagnostics = &diagnostics,
4971 }),4924 }),
4972 );4925 );
4973 try std.testing.expectEqual(4926 try std.testing.expectEqual(
...@@ -4976,7 +4929,7 @@ test "std.zon variants" {...@@ -4976,7 +4929,7 @@ test "std.zon variants" {
4976 .gpa = gpa,4929 .gpa = gpa,
4977 .arena = arena,4930 .arena = arena,
4978 .source = ".{ .a = 100, .b = 20 }",4931 .source = ".{ .a = 100, .b = 20 }",
4979 .errors = &errors,4932 .diagnostics = &diagnostics,
4980 }),4933 }),
4981 );4934 );
4982 try std.testing.expectEqual(4935 try std.testing.expectEqual(
...@@ -4984,7 +4937,7 @@ test "std.zon variants" {...@@ -4984,7 +4937,7 @@ test "std.zon variants" {
4984 .arena = arena,4937 .arena = arena,
4985 .ast = &ast,4938 .ast = &ast,
4986 .zoir = &zoir,4939 .zoir = &zoir,
4987 .errors = &errors,4940 .diagnostics = &diagnostics,
4988 }),4941 }),
4989 end,4942 end,
4990 );4943 );
...@@ -4993,7 +4946,7 @@ test "std.zon variants" {...@@ -4993,7 +4946,7 @@ test "std.zon variants" {
4993 .arena = arena,4946 .arena = arena,
4994 .ast = &ast,4947 .ast = &ast,
4995 .zoir = &zoir,4948 .zoir = &zoir,
4996 .errors = &errors,4949 .diagnostics = &diagnostics,
4997 }),4950 }),
4998 end,4951 end,
4999 );4952 );
...@@ -5001,5 +4954,5 @@ test "std.zon variants" {...@@ -5001,5 +4954,5 @@ test "std.zon variants" {
5001}4954}
50024955
5003test {4956test {
5004 _ = Errors;4957 _ = Diagnostics;
5005}4958}