mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
Sema: correct implementation of comptimeOnly for tuples
This makes formatted printing work when mixing comptime and runtime fields.
This commit is contained in:
parent
f6aaab9406
commit
8878f085dc
@ -19585,8 +19585,9 @@ fn typeRequiresComptime(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) C
|
||||
|
||||
.tuple => {
|
||||
const tuple = ty.castTag(.tuple).?.data;
|
||||
for (tuple.types) |field_ty| {
|
||||
if (try sema.typeRequiresComptime(block, src, field_ty)) {
|
||||
for (tuple.types) |field_ty, i| {
|
||||
const have_comptime_val = tuple.values[i].tag() != .unreachable_value;
|
||||
if (!have_comptime_val and try sema.typeRequiresComptime(block, src, field_ty)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4050,8 +4050,9 @@ pub const Type = extern union {
|
||||
|
||||
.tuple => {
|
||||
const tuple = ty.castTag(.tuple).?.data;
|
||||
for (tuple.types) |field_ty| {
|
||||
if (field_ty.comptimeOnly()) return true;
|
||||
for (tuple.types) |field_ty, i| {
|
||||
const have_comptime_val = tuple.values[i].tag() != .unreachable_value;
|
||||
if (!have_comptime_val and field_ty.comptimeOnly()) return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
@ -45,7 +45,7 @@ test "tuple multiplication" {
|
||||
comptime try S.doTheTest();
|
||||
}
|
||||
|
||||
test "tuple concatenation" {
|
||||
test "more tuple concatenation" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
|
||||
const T = struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user