aboutsummaryrefslogtreecommitdiff
path: root/test/incremental/change_exports
blob: b0850626d6ed01395bcf7f134f700e3ad34b64f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#target=x86_64-linux-selfhosted
#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe

#update=initial version
#file=main.zig
export fn foo() void {}
const bar: u32 = 123;
const other: u32 = 456;
comptime {
    @export(&bar, .{ .name = "bar" });
}
pub fn main() !void {
    const S = struct {
        extern fn foo() void;
        extern const bar: u32;
    };
    S.foo();
    var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
    try stdout_writer.interface.print("{}\n", .{S.bar});
}
const std = @import("std");
#expect_stdout="123\n"

#update=add conflict
#file=main.zig
export fn foo() void {}
const bar: u32 = 123;
const other: u32 = 456;
comptime {
    @export(&bar, .{ .name = "bar" });
    @export(&other, .{ .name = "foo" });
}
pub fn main() !void {
    const S = struct {
        extern fn foo() void;
        extern const bar: u32;
        extern const other: u32;
    };
    S.foo();
    var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
    try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
}
const std = @import("std");
#expect_error=main.zig:6:5: error: exported symbol collision: foo
#expect_error=main.zig:1:1: note: other symbol here

#update=resolve conflict
#file=main.zig
export fn foo() void {}
const bar: u32 = 123;
const other: u32 = 456;
comptime {
    @export(&bar, .{ .name = "bar" });
    @export(&other, .{ .name = "other" });
}
pub fn main() !void {
    const S = struct {
        extern fn foo() void;
        extern const bar: u32;
        extern const other: u32;
    };
    S.foo();
    var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
    try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
}
const std = @import("std");
#expect_stdout="123 456\n"

#update=put exports in decl
#file=main.zig
export fn foo() void {}
const bar: u32 = 123;
const other: u32 = 456;
const does_exports = {
    @export(&bar, .{ .name = "bar" });
    @export(&other, .{ .name = "other" });
};
comptime {
    _ = does_exports;
}
pub fn main() !void {
    const S = struct {
        extern fn foo() void;
        extern const bar: u32;
        extern const other: u32;
    };
    S.foo();
    var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
    try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
}
const std = @import("std");
#expect_stdout="123 456\n"

#update=remove reference to exporting decl
#file=main.zig
export fn foo() void {}
const bar: u32 = 123;
const other: u32 = 456;
const does_exports = {
    @export(&bar, .{ .name = "bar" });
    @export(&other, .{ .name = "other" });
};
comptime {
    //_ = does_exports;
}
pub fn main() !void {
    const S = struct {
        extern fn foo() void;
    };
    S.foo();
}
const std = @import("std");
#expect_stdout=""

#update=mark consts as export
#file=main.zig
export fn foo() void {}
export const bar: u32 = 123;
export const other: u32 = 456;
const does_exports = {
    @export(&bar, .{ .name = "bar" });
    @export(&other, .{ .name = "other" });
};
comptime {
    //_ = does_exports;
}
pub fn main() !void {
    const S = struct {
        extern fn foo() void;
        extern const bar: u32;
        extern const other: u32;
    };
    S.foo();
    var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
    try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
}
const std = @import("std");
#expect_stdout="123 456\n"

#update=reintroduce reference to exporting decl, introducing conflict
#file=main.zig
export fn foo() void {}
export const bar: u32 = 123;
export const other: u32 = 456;
const does_exports = {
    @export(&bar, .{ .name = "bar" });
    @export(&other, .{ .name = "other" });
};
comptime {
    _ = does_exports;
}
pub fn main() !void {
    const S = struct {
        extern fn foo() void;
        extern const bar: u32;
        extern const other: u32;
    };
    S.foo();
    var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
    try stdout_writer.interface.print("{} {}\n", .{ S.bar, S.other });
}
const std = @import("std");
#expect_error=main.zig:5:5: error: exported symbol collision: bar
#expect_error=main.zig:2:1: note: other symbol here
#expect_error=main.zig:6:5: error: exported symbol collision: other
#expect_error=main.zig:3:1: note: other symbol here