Skip to content

Commit 3a25f6a

Browse files
mluggandrewrk
authored andcommitted
Port some stage1 test cases to stage2
There are now very few stage1 cases remaining: * `cases/compile_errors/stage1/obj/*` currently don't work correctly on stage2. There are 6 of these, and most of them are probably fairly simple to fix. * `cases/compile_errors/async/*` and all remaining `safety/*` depend on async; see #6025. Resolves: #14849
1 parent 626a75b commit 3a25f6a

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

test/cases/compile_errors/undefined_as_field_type_is_rejected.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export fn entry1() void {
77
}
88

99
// error
10-
// backend=stage1
10+
// backend=stage2
1111
// target=native
1212
//
13-
// tmp.zig:2:8: error: use of undefined value here causes undefined behavior
13+
// :2:8: error: use of undefined value here causes undefined behavior

test/compile_errors.zig

+47
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,51 @@ pub fn addCases(ctx: *Cases) !void {
136136
\\const dummy = 0;
137137
);
138138
}
139+
140+
{
141+
const case = ctx.obj("wrong same named struct", .{});
142+
143+
case.addError(
144+
\\const a = @import("a.zig");
145+
\\const b = @import("b.zig");
146+
\\
147+
\\export fn entry() void {
148+
\\ var a1: a.Foo = undefined;
149+
\\ bar(&a1);
150+
\\}
151+
\\
152+
\\fn bar(_: *b.Foo) void {}
153+
, &[_][]const u8{
154+
":6:9: error: expected type '*b.Foo', found '*a.Foo'",
155+
":6:9: note: pointer type child 'a.Foo' cannot cast into pointer type child 'b.Foo'",
156+
":1:17: note: struct declared here",
157+
":1:17: note: struct declared here",
158+
":9:11: note: parameter type declared here",
159+
});
160+
161+
case.addSourceFile("a.zig",
162+
\\pub const Foo = struct {
163+
\\ x: i32,
164+
\\};
165+
);
166+
167+
case.addSourceFile("b.zig",
168+
\\pub const Foo = struct {
169+
\\ z: f64,
170+
\\};
171+
);
172+
}
173+
174+
{
175+
const case = ctx.obj("non-printable invalid character", .{});
176+
177+
case.addError("\xff\xfe" ++
178+
\\export fn foo() bool {
179+
\\ return true;
180+
\\}
181+
, &[_][]const u8{
182+
":1:1: error: expected type expression, found 'invalid bytes'",
183+
":1:1: note: invalid byte: '\\xff'",
184+
});
185+
}
139186
}

0 commit comments

Comments
 (0)