aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-02-01 20:50:43 +0200
committerVeikka Tuominen <git@vexu.eu>2023-02-01 20:50:43 +0200
commit490addde278001694d554a9a9fe2eb8235831143 (patch)
tree93c966416c0a767200ce82e199661690cd9f76c9 /src/Sema.zig
parentf3bb1957fa7f317873584cfc0ea8e3fd59283ec2 (diff)
downloadzig-490addde278001694d554a9a9fe2eb8235831143.tar.gz
zig-490addde278001694d554a9a9fe2eb8235831143.zip
Sema: fix error location on comptime arg to typed generic param
Closes #14505
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index d306c68e08..4615c5b162 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -9015,7 +9015,18 @@ fn zirParam(
if (is_comptime and sema.preallocated_new_func != null) {
// We have a comptime value for this parameter so it should be elided from the
// function type of the function instruction in this block.
- const coerced_arg = try sema.coerce(block, param_ty, arg, src);
+ const coerced_arg = sema.coerce(block, param_ty, arg, .unneeded) catch |err| switch (err) {
+ error.NeededSourceLocation => {
+ // We are instantiating a generic function and a comptime arg
+ // cannot be coerced to the param type, but since we don't
+ // have the callee source location return `GenericPoison`
+ // so that the instantiation is failed and the coercion
+ // is handled by comptime call logic instead.
+ assert(sema.is_generic_instantiation);
+ return error.GenericPoison;
+ },
+ else => return err,
+ };
sema.inst_map.putAssumeCapacity(inst, coerced_arg);
return;
}