-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
do not enforce function parameters to be marked comptime if only called at comptime #18331
Conversation
nice |
Provide an example here in case it helps: const std = @import("std");
const EnumMap = std.EnumMap;
const Ty = enum(u8) {
a,
b,
};
const HANDLERS_MAP = EnumMap(Ty, fn () callconv(.Inline) void).init(.{
.a = fa,
.b = fb,
});
inline fn fa() void {
std.debug.print("fa\n", .{});
}
inline fn fb() void {
std.debug.print("fb\n", .{});
}
pub fn main() !void {
const ty = Ty.b;
HANDLERS_MAP.get(ty).?();
} After adding each
Successfully compiled. |
yes, without this change using many structures with comptime-only types is impossible while making it so they can continue to work with runtime types as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lacks a behavior test.
outside the one |
Yes, the goal is for all behavior to be covered by behavior tests. Standard library tests are intended only to provide coverage for the standard library functionality; they are not double-purposed as coverage for the language itself. |
Fixes #18321
Fixes #16454
Fixes #1383