-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Closed
Copy link
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone
Description
Zig Version
0.10.0-dev.1335+c64279b15
Steps to Reproduce
The test program is below: Note:
- The
switchreturn type is required for the function sig. - The
switchreturn value is required for the function body. - The function call is required
- If you wrap the whole test in a
comptime {}block it works.
const std = @import("std");
const Type = std.builtin.Type;
test "Tuple" {
const fields_list = fields(@TypeOf(.{}));
if (fields_list.len != 0)
@compileError("Argument count mismatch");
}
pub fn fields(comptime T: type) switch (@typeInfo(T)) {
.Struct => []const Type.StructField,
else => unreachable,
} {
return switch (@typeInfo(T)) {
.Struct => |info| info.fields,
else => unreachable,
};
}Expected Behavior
Should not have any errors (stage1 works), since fields.len should be comptime known.
The reason: this is how std.meta tests Tuple and ArgsTuple, so this is exercised in the stdlib.
Actual Behavior
Triggers @compileError
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.