aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2023-03-17 12:27:19 +0000
committerAndrew Kelley <andrew@ziglang.org>2023-03-20 19:55:50 -0400
commit3a25f6a22e0f339fcaecc87efb0fa4e5f67bd73c (patch)
tree92858bf958239ef553a9e8a185b261c6f4136cf8 /test/compile_errors.zig
parent626a75bbc21453237f95c186d1fea790f233bc58 (diff)
downloadzig-3a25f6a22e0f339fcaecc87efb0fa4e5f67bd73c.tar.gz
zig-3a25f6a22e0f339fcaecc87efb0fa4e5f67bd73c.zip
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
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 2d796b9463..5a60ef2e55 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -136,4 +136,51 @@ pub fn addCases(ctx: *Cases) !void {
\\const dummy = 0;
);
}
+
+ {
+ const case = ctx.obj("wrong same named struct", .{});
+
+ case.addError(
+ \\const a = @import("a.zig");
+ \\const b = @import("b.zig");
+ \\
+ \\export fn entry() void {
+ \\ var a1: a.Foo = undefined;
+ \\ bar(&a1);
+ \\}
+ \\
+ \\fn bar(_: *b.Foo) void {}
+ , &[_][]const u8{
+ ":6:9: error: expected type '*b.Foo', found '*a.Foo'",
+ ":6:9: note: pointer type child 'a.Foo' cannot cast into pointer type child 'b.Foo'",
+ ":1:17: note: struct declared here",
+ ":1:17: note: struct declared here",
+ ":9:11: note: parameter type declared here",
+ });
+
+ case.addSourceFile("a.zig",
+ \\pub const Foo = struct {
+ \\ x: i32,
+ \\};
+ );
+
+ case.addSourceFile("b.zig",
+ \\pub const Foo = struct {
+ \\ z: f64,
+ \\};
+ );
+ }
+
+ {
+ const case = ctx.obj("non-printable invalid character", .{});
+
+ case.addError("\xff\xfe" ++
+ \\export fn foo() bool {
+ \\ return true;
+ \\}
+ , &[_][]const u8{
+ ":1:1: error: expected type expression, found 'invalid bytes'",
+ ":1:1: note: invalid byte: '\\xff'",
+ });
+ }
}