1#update=initial version
2#file=main.zig
3export fn foo() void {}
4const bar: u32 = 123;
5const other: u32 = 456;
6comptime {
7 @export(&bar, .{ .name = "bar" });
8}
9pub fn main() !void {
10 const S = struct {
11 extern fn foo() void;
12 extern const bar: u32;
13 };
14 S.foo();
15 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
16 try stdout_writer.interface.print("{}\n", .{S.bar});
17}
18const std = @import("std");
19const io = std.Io.Threaded.global_single_threaded.io();
20#expect_stdout="123\n"
21
22#update=add conflict
23#file=main.zig
24export fn foo() void {}
25const bar: u32 = 123;
26const other: u32 = 456;
27comptime {
28 @export(&bar, .{ .name = "bar" });
29 @export(&other, .{ .name = "foo" });
30}
31pub fn main() !void {
32 const S = struct {
33 extern fn foo() void;
34 extern const bar: u32;
35 extern const other: u32;
36 };
37 S.foo();
38 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
39 try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
40}
41const std = @import("std");
42const io = std.Io.Threaded.global_single_threaded.io();
43#expect_error=main.zig:6:5: error: exported symbol collision: foo
44#expect_error=main.zig:1:1: note: other symbol here
45
46#update=resolve conflict
47#file=main.zig
48export fn foo() void {}
49const bar: u32 = 123;
50const other: u32 = 456;
51comptime {
52 @export(&bar, .{ .name = "bar" });
53 @export(&other, .{ .name = "other" });
54}
55pub fn main() !void {
56 const S = struct {
57 extern fn foo() void;
58 extern const bar: u32;
59 extern const other: u32;
60 };
61 S.foo();
62 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
63 try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
64}
65const std = @import("std");
66const io = std.Io.Threaded.global_single_threaded.io();
67#expect_stdout="123 456\n"
68
69#update=put exports in decl
70#file=main.zig
71export fn foo() void {}
72const bar: u32 = 123;
73const other: u32 = 456;
74const does_exports = {
75 @export(&bar, .{ .name = "bar" });
76 @export(&other, .{ .name = "other" });
77};
78comptime {
79 _ = does_exports;
80}
81pub fn main() !void {
82 const S = struct {
83 extern fn foo() void;
84 extern const bar: u32;
85 extern const other: u32;
86 };
87 S.foo();
88 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
89 try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
90}
91const std = @import("std");
92const io = std.Io.Threaded.global_single_threaded.io();
93#expect_stdout="123 456\n"
94
95#update=remove reference to exporting decl
96#file=main.zig
97export fn foo() void {}
98const bar: u32 = 123;
99const other: u32 = 456;
100const does_exports = {
101 @export(&bar, .{ .name = "bar" });
102 @export(&other, .{ .name = "other" });
103};
104comptime {
105 //_ = does_exports;
106}
107pub fn main() !void {
108 const S = struct {
109 extern fn foo() void;
110 };
111 S.foo();
112}
113const std = @import("std");
114#expect_stdout=""
115
116#update=mark consts as export
117#file=main.zig
118export fn foo() void {}
119export const bar: u32 = 123;
120export const other: u32 = 456;
121const does_exports = {
122 @export(&bar, .{ .name = "bar" });
123 @export(&other, .{ .name = "other" });
124};
125comptime {
126 //_ = does_exports;
127}
128pub fn main() !void {
129 const S = struct {
130 extern fn foo() void;
131 extern const bar: u32;
132 extern const other: u32;
133 };
134 S.foo();
135 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
136 try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
137}
138const std = @import("std");
139const io = std.Io.Threaded.global_single_threaded.io();
140#expect_stdout="123 456\n"
141
142#update=reintroduce reference to exporting decl, introducing conflict
143#file=main.zig
144export fn foo() void {}
145export const bar: u32 = 123;
146export const other: u32 = 456;
147const does_exports = {
148 @export(&bar, .{ .name = "bar" });
149 @export(&other, .{ .name = "other" });
150};
151comptime {
152 _ = does_exports;
153}
154pub fn main() !void {
155 const S = struct {
156 extern fn foo() void;
157 extern const bar: u32;
158 extern const other: u32;
159 };
160 S.foo();
161 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
162 try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
163}
164const std = @import("std");
165const io = std.Io.Threaded.global_single_threaded.io();
166#expect_error=main.zig:5:5: error: exported symbol collision: bar
167#expect_error=main.zig:2:1: note: other symbol here
168#expect_error=main.zig:6:5: error: exported symbol collision: other
169#expect_error=main.zig:3:1: note: other symbol here