aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-08-09 11:38:47 -0700
committerGitHub <noreply@github.com>2023-08-09 11:38:47 -0700
commit72c68f698ed2153f2a9e3b2c7166fa03bb03ae1a (patch)
tree68d5adadb029c03beb65a70aaf8ed35bd2620fea /test/compile_errors.zig
parent9676a43a5d36693c884cda53220cbee1ad9de4d5 (diff)
parent57470e833e4ac545a75ad7b3dd6830fa666cd325 (diff)
downloadzig-72c68f698ed2153f2a9e3b2c7166fa03bb03ae1a.tar.gz
zig-72c68f698ed2153f2a9e3b2c7166fa03bb03ae1a.zip
Merge pull request #16752 from jacobly0/generic-srclocs
Sema: fix issues with source locations of generic arguments
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 5a60ef2e55..8675eb9ed7 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -183,4 +183,40 @@ pub fn addCases(ctx: *Cases) !void {
":1:1: note: invalid byte: '\\xff'",
});
}
+
+ {
+ const case = ctx.obj("imported generic method call with invalid param", .{});
+
+ case.addError(
+ \\pub const import = @import("import.zig");
+ \\
+ \\export fn callComptimeBoolFunctionWithRuntimeBool(x: bool) void {
+ \\ import.comptimeBoolFunction(x);
+ \\}
+ \\
+ \\export fn callComptimeAnytypeFunctionWithRuntimeBool(x: bool) void {
+ \\ import.comptimeAnytypeFunction(x);
+ \\}
+ \\
+ \\export fn callAnytypeFunctionWithRuntimeComptimeOnlyType(x: u32) void {
+ \\ const S = struct { x: u32, y: type };
+ \\ import.anytypeFunction(S{ .x = x, .y = u32 });
+ \\}
+ , &[_][]const u8{
+ ":4:33: error: runtime-known argument passed to comptime parameter",
+ ":1:38: note: declared comptime here",
+ ":8:36: error: runtime-known argument passed to comptime parameter",
+ ":2:41: note: declared comptime here",
+ ":13:29: error: runtime-known argument passed to comptime-only type parameter",
+ ":3:24: note: declared here",
+ ":12:35: note: struct requires comptime because of this field",
+ ":12:35: note: types are not available at runtime",
+ });
+
+ case.addSourceFile("import.zig",
+ \\pub fn comptimeBoolFunction(comptime _: bool) void {}
+ \\pub fn comptimeAnytypeFunction(comptime _: anytype) void {}
+ \\pub fn anytypeFunction(_: anytype) void {}
+ );
+ }
}