From 13c6eb0d71b253cc55a667e33dbdd4932f3710f1 Mon Sep 17 00:00:00 2001 From: Mason Remaley Date: Mon, 4 Nov 2024 14:03:36 -0800 Subject: compiler,std: implement ZON support This commit allows using ZON (Zig Object Notation) in a few ways. * `@import` can be used to load ZON at comptime and convert it to a normal Zig value. In this case, `@import` must have a result type. * `std.zon.parse` can be used to parse ZON at runtime, akin to the parsing logic in `std.json`. * `std.zon.stringify` can be used to convert arbitrary data structures to ZON at runtime, again akin to `std.json`. --- test/cases/compile_errors/@import_zon_unknown_ident.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/cases/compile_errors/@import_zon_unknown_ident.zig (limited to 'test/cases/compile_errors/@import_zon_unknown_ident.zig') diff --git a/test/cases/compile_errors/@import_zon_unknown_ident.zig b/test/cases/compile_errors/@import_zon_unknown_ident.zig new file mode 100644 index 0000000000..cf3ff652b5 --- /dev/null +++ b/test/cases/compile_errors/@import_zon_unknown_ident.zig @@ -0,0 +1,11 @@ +export fn entry() void { + const f: struct { value: bool } = @import("zon/unknown_ident.zon"); + _ = f; +} + +// error +// imports=zon/unknown_ident.zon +// +// unknown_ident.zon:2:14: error: invalid expression +// unknown_ident.zon:2:14: note: ZON allows identifiers 'true', 'false', 'null', 'inf', and 'nan' +// unknown_ident.zon:2:14: note: precede identifier with '.' for an enum literal -- cgit v1.2.3