aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-08-05 03:31:33 -0400
committerAndrew Kelley <andrew@ziglang.org>2023-08-05 11:21:50 -0700
commita91a8df6791b6fe228ad616acd9fbbde46451651 (patch)
treee7a9990cb09ecb53e2a90a6c9c2fbbf68540a5e3 /test/cases/compile_errors
parentfc6e5756848cd627b69756853937ce22500e62cc (diff)
downloadzig-a91a8df6791b6fe228ad616acd9fbbde46451651.tar.gz
zig-a91a8df6791b6fe228ad616acd9fbbde46451651.zip
Sema: fix issues passing an invalid type to a generic method
Closes #16601
Diffstat (limited to 'test/cases/compile_errors')
-rw-r--r--test/cases/compile_errors/generic_method_call_invalid_coercion.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/cases/compile_errors/generic_method_call_invalid_coercion.zig b/test/cases/compile_errors/generic_method_call_invalid_coercion.zig
new file mode 100644
index 0000000000..59fa50da37
--- /dev/null
+++ b/test/cases/compile_errors/generic_method_call_invalid_coercion.zig
@@ -0,0 +1,21 @@
+export fn callBoolMethod() void {
+ const s = S{};
+ s.boolMethod({});
+}
+
+export fn callVoidMethod() void {
+ const s = S{};
+ s.voidMethod(false);
+}
+
+const S = struct {
+ fn boolMethod(comptime _: @This(), _: bool) void {}
+ fn voidMethod(comptime _: @This(), _: void) void {}
+};
+
+// error
+// backend=stage2
+// target=native
+//
+// :3:18: error: expected type 'bool', found 'void'
+// :8:18: error: expected type 'void', found 'bool'