| 1 | #update=initial version |
| 2 | #file=main.zig |
| 3 | export fn foo() void {} |
| 4 | const bar: u32 = 123; |
| 5 | const other: u32 = 456; |
| 6 | comptime { |
| 7 | @export(&bar, .{ .name = "bar" }); |
| 8 | } |
| 9 | pub 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 | } |
| 18 | const std = @import("std"); |
| 19 | const io = std.Io.Threaded.global_single_threaded.io(); |
| 20 | #expect_stdout="123\n" |
| 21 | |
| 22 | #update=add conflict |
| 23 | #file=main.zig |
| 24 | export fn foo() void {} |
| 25 | const bar: u32 = 123; |
| 26 | const other: u32 = 456; |
| 27 | comptime { |
| 28 | @export(&bar, .{ .name = "bar" }); |
| 29 | @export(&other, .{ .name = "foo" }); |
| 30 | } |
| 31 | pub 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 | } |
| 41 | const std = @import("std"); |
| 42 | const 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 |
| 48 | export fn foo() void {} |
| 49 | const bar: u32 = 123; |
| 50 | const other: u32 = 456; |
| 51 | comptime { |
| 52 | @export(&bar, .{ .name = "bar" }); |
| 53 | @export(&other, .{ .name = "other" }); |
| 54 | } |
| 55 | pub 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 | } |
| 65 | const std = @import("std"); |
| 66 | const 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 |
| 71 | export fn foo() void {} |
| 72 | const bar: u32 = 123; |
| 73 | const other: u32 = 456; |
| 74 | const does_exports = { |
| 75 | @export(&bar, .{ .name = "bar" }); |
| 76 | @export(&other, .{ .name = "other" }); |
| 77 | }; |
| 78 | comptime { |
| 79 | _ = does_exports; |
| 80 | } |
| 81 | pub 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 | } |
| 91 | const std = @import("std"); |
| 92 | const 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 |
| 97 | export fn foo() void {} |
| 98 | const bar: u32 = 123; |
| 99 | const other: u32 = 456; |
| 100 | const does_exports = { |
| 101 | @export(&bar, .{ .name = "bar" }); |
| 102 | @export(&other, .{ .name = "other" }); |
| 103 | }; |
| 104 | comptime { |
| 105 | //_ = does_exports; |
| 106 | } |
| 107 | pub fn main() !void { |
| 108 | const S = struct { |
| 109 | extern fn foo() void; |
| 110 | }; |
| 111 | S.foo(); |
| 112 | } |
| 113 | const std = @import("std"); |
| 114 | #expect_stdout="" |
| 115 | |
| 116 | #update=mark consts as export |
| 117 | #file=main.zig |
| 118 | export fn foo() void {} |
| 119 | export const bar: u32 = 123; |
| 120 | export const other: u32 = 456; |
| 121 | const does_exports = { |
| 122 | @export(&bar, .{ .name = "bar" }); |
| 123 | @export(&other, .{ .name = "other" }); |
| 124 | }; |
| 125 | comptime { |
| 126 | //_ = does_exports; |
| 127 | } |
| 128 | pub 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 | } |
| 138 | const std = @import("std"); |
| 139 | const 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 |
| 144 | export fn foo() void {} |
| 145 | export const bar: u32 = 123; |
| 146 | export const other: u32 = 456; |
| 147 | const does_exports = { |
| 148 | @export(&bar, .{ .name = "bar" }); |
| 149 | @export(&other, .{ .name = "other" }); |
| 150 | }; |
| 151 | comptime { |
| 152 | _ = does_exports; |
| 153 | } |
| 154 | pub 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 | } |
| 164 | const std = @import("std"); |
| 165 | const 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 |