diff options
| author | Meghan Denny <hello@nektro.net> | 2024-01-19 00:35:45 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-19 15:31:18 -0800 |
| commit | 46d592e485cf8ee4d85854040acd1b05271591b5 (patch) | |
| tree | 3c6de775a40405360f3ca216e2e4c205851404c4 /src/Sema.zig | |
| parent | d7b6d637df5b94ec07cf017fa742e8c34a4b9433 (diff) | |
| download | zig-46d592e485cf8ee4d85854040acd1b05271591b5.tar.gz zig-46d592e485cf8ee4d85854040acd1b05271591b5.zip | |
do not enforce function parameters to be marked comptime if only called at comptime
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index d86a8ef2f0..a38da0adef 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -9302,7 +9302,7 @@ fn funcCommon( }; return sema.failWithOwnedErrorMsg(block, msg); } - if (is_source_decl and requires_comptime and !param_is_comptime and has_body) { + if (is_source_decl and requires_comptime and !param_is_comptime and has_body and !block.is_comptime) { const msg = msg: { const msg = try sema.errMsg(block, param_src, "parameter of type '{}' must be declared comptime", .{ param_ty.fmt(mod), @@ -9597,7 +9597,7 @@ fn finishFunc( // If the return type is comptime-only but not dependent on parameters then // all parameter types also need to be comptime. - if (is_source_decl and opt_func_index != .none and ret_ty_requires_comptime) comptime_check: { + if (is_source_decl and opt_func_index != .none and ret_ty_requires_comptime and !block.is_comptime) comptime_check: { for (block.params.items(.is_comptime)) |is_comptime| { if (!is_comptime) break; } else break :comptime_check; |
