| ... | @@ -0,0 +1,161 @@ |
| 1 | #target=x86_64-linux-selfhosted |
| 2 | #target=x86_64-linux-cbe |
| 3 | #target=x86_64-windows-cbe |
| 4 | |
| 5 | #update=initial version |
| 6 | #file=main.zig |
| 7 | export fn foo() void {} |
| 8 | const bar: u32 = 123; |
| 9 | const other: u32 = 456; |
| 10 | comptime { |
| 11 | @export(&bar, .{ .name = "bar" }); |
| 12 | } |
| 13 | pub fn main() !void { |
| 14 | const S = struct { |
| 15 | extern fn foo() void; |
| 16 | extern const bar: u32; |
| 17 | }; |
| 18 | S.foo(); |
| 19 | try std.io.getStdOut().writer().print("{}\n", .{S.bar}); |
| 20 | } |
| 21 | const std = @import("std"); |
| 22 | #expect_stdout="123\n" |
| 23 | |
| 24 | #update=add conflict |
| 25 | #file=main.zig |
| 26 | export fn foo() void {} |
| 27 | const bar: u32 = 123; |
| 28 | const other: u32 = 456; |
| 29 | comptime { |
| 30 | @export(&bar, .{ .name = "bar" }); |
| 31 | @export(&other, .{ .name = "foo" }); |
| 32 | } |
| 33 | pub fn main() !void { |
| 34 | const S = struct { |
| 35 | extern fn foo() void; |
| 36 | extern const bar: u32; |
| 37 | extern const other: u32; |
| 38 | }; |
| 39 | S.foo(); |
| 40 | try std.io.getStdOut().writer().print("{} {}\n", .{ S.bar, S.other }); |
| 41 | } |
| 42 | const std = @import("std"); |
| 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 | try std.io.getStdOut().writer().print("{} {}\n", .{ S.bar, S.other }); |
| 63 | } |
| 64 | const std = @import("std"); |
| 65 | #expect_stdout="123 456\n" |
| 66 | |
| 67 | #update=put exports in decl |
| 68 | #file=main.zig |
| 69 | export fn foo() void {} |
| 70 | const bar: u32 = 123; |
| 71 | const other: u32 = 456; |
| 72 | const does_exports = { |
| 73 | @export(&bar, .{ .name = "bar" }); |
| 74 | @export(&other, .{ .name = "other" }); |
| 75 | }; |
| 76 | comptime { |
| 77 | _ = does_exports; |
| 78 | } |
| 79 | pub fn main() !void { |
| 80 | const S = struct { |
| 81 | extern fn foo() void; |
| 82 | extern const bar: u32; |
| 83 | extern const other: u32; |
| 84 | }; |
| 85 | S.foo(); |
| 86 | try std.io.getStdOut().writer().print("{} {}\n", .{ S.bar, S.other }); |
| 87 | } |
| 88 | const std = @import("std"); |
| 89 | #expect_stdout="123 456\n" |
| 90 | |
| 91 | #update=remove reference to exporting decl |
| 92 | #file=main.zig |
| 93 | export fn foo() void {} |
| 94 | const bar: u32 = 123; |
| 95 | const other: u32 = 456; |
| 96 | const does_exports = { |
| 97 | @export(&bar, .{ .name = "bar" }); |
| 98 | @export(&other, .{ .name = "other" }); |
| 99 | }; |
| 100 | comptime { |
| 101 | //_ = does_exports; |
| 102 | } |
| 103 | pub fn main() !void { |
| 104 | const S = struct { |
| 105 | extern fn foo() void; |
| 106 | }; |
| 107 | S.foo(); |
| 108 | } |
| 109 | const std = @import("std"); |
| 110 | #expect_stdout="" |
| 111 | |
| 112 | #update=mark consts as export |
| 113 | #file=main.zig |
| 114 | export fn foo() void {} |
| 115 | export const bar: u32 = 123; |
| 116 | export const other: u32 = 456; |
| 117 | const does_exports = { |
| 118 | @export(&bar, .{ .name = "bar" }); |
| 119 | @export(&other, .{ .name = "other" }); |
| 120 | }; |
| 121 | comptime { |
| 122 | //_ = does_exports; |
| 123 | } |
| 124 | pub fn main() !void { |
| 125 | const S = struct { |
| 126 | extern fn foo() void; |
| 127 | extern const bar: u32; |
| 128 | extern const other: u32; |
| 129 | }; |
| 130 | S.foo(); |
| 131 | try std.io.getStdOut().writer().print("{} {}\n", .{ S.bar, S.other }); |
| 132 | } |
| 133 | const std = @import("std"); |
| 134 | #expect_stdout="123 456\n" |
| 135 | |
| 136 | #update=reintroduce reference to exporting decl, introducing conflict |
| 137 | #file=main.zig |
| 138 | export fn foo() void {} |
| 139 | export const bar: u32 = 123; |
| 140 | export const other: u32 = 456; |
| 141 | const does_exports = { |
| 142 | @export(&bar, .{ .name = "bar" }); |
| 143 | @export(&other, .{ .name = "other" }); |
| 144 | }; |
| 145 | comptime { |
| 146 | _ = does_exports; |
| 147 | } |
| 148 | pub fn main() !void { |
| 149 | const S = struct { |
| 150 | extern fn foo() void; |
| 151 | extern const bar: u32; |
| 152 | extern const other: u32; |
| 153 | }; |
| 154 | S.foo(); |
| 155 | try std.io.getStdOut().writer().print("{} {}\n", .{ S.bar, S.other }); |
| 156 | } |
| 157 | const std = @import("std"); |
| 158 | #expect_error=main.zig:5:5: error: exported symbol collision: bar |
| 159 | #expect_error=main.zig:2:1: note: other symbol here |
| 160 | #expect_error=main.zig:6:5: error: exported symbol collision: other |
| 161 | #expect_error=main.zig:3:1: note: other symbol here |