| ... | ... | @@ -1544,22 +1544,40 @@ pub const Type = extern union { |
| 1544 | 1544 | |
| 1545 | 1545 | .@"struct" => { |
| 1546 | 1546 | const struct_obj = ty.castTag(.@"struct").?.data; |
| 1547 | | for (struct_obj.fields.values()) |field| { |
| 1548 | | if (requiresComptime(field.ty)) { |
| 1549 | | return true; |
| 1550 | | } |
| 1547 | switch (struct_obj.requires_comptime) { |
| 1548 | .no, .wip => return false, |
| 1549 | .yes => return true, |
| 1550 | .unknown => { |
| 1551 | struct_obj.requires_comptime = .wip; |
| 1552 | for (struct_obj.fields.values()) |field| { |
| 1553 | if (requiresComptime(field.ty)) { |
| 1554 | struct_obj.requires_comptime = .yes; |
| 1555 | return true; |
| 1556 | } |
| 1557 | } |
| 1558 | struct_obj.requires_comptime = .no; |
| 1559 | return false; |
| 1560 | }, |
| 1551 | 1561 | } |
| 1552 | | return false; |
| 1553 | 1562 | }, |
| 1554 | 1563 | |
| 1555 | 1564 | .@"union", .union_tagged => { |
| 1556 | 1565 | const union_obj = ty.cast(Payload.Union).?.data; |
| 1557 | | for (union_obj.fields.values()) |field| { |
| 1558 | | if (requiresComptime(field.ty)) { |
| 1559 | | return true; |
| 1560 | | } |
| 1566 | switch (union_obj.requires_comptime) { |
| 1567 | .no, .wip => return false, |
| 1568 | .yes => return true, |
| 1569 | .unknown => { |
| 1570 | union_obj.requires_comptime = .wip; |
| 1571 | for (union_obj.fields.values()) |field| { |
| 1572 | if (requiresComptime(field.ty)) { |
| 1573 | union_obj.requires_comptime = .yes; |
| 1574 | return true; |
| 1575 | } |
| 1576 | } |
| 1577 | union_obj.requires_comptime = .no; |
| 1578 | return false; |
| 1579 | }, |
| 1561 | 1580 | } |
| 1562 | | return false; |
| 1563 | 1581 | }, |
| 1564 | 1582 | |
| 1565 | 1583 | .error_union => return requiresComptime(errorUnionPayload(ty)), |
| ... | ... | @@ -3661,7 +3679,7 @@ pub const Type = extern union { |
| 3661 | 3679 | .Slice, .Many, .C => true, |
| 3662 | 3680 | .One => ty.elemType().zigTypeTag() == .Array, |
| 3663 | 3681 | }, |
| 3664 | | .Struct => ty.tag() == .tuple, |
| 3682 | .Struct => ty.isTuple(), |
| 3665 | 3683 | else => false, |
| 3666 | 3684 | }; |
| 3667 | 3685 | } |
| ... | ... | @@ -4501,6 +4519,10 @@ pub const Type = extern union { |
| 4501 | 4519 | } |
| 4502 | 4520 | }; |
| 4503 | 4521 | |
| 4522 | pub fn isTuple(ty: Type) bool { |
| 4523 | return ty.tag() == .tuple; |
| 4524 | } |
| 4525 | |
| 4504 | 4526 | /// The sub-types are named after what fields they contain. |
| 4505 | 4527 | pub const Payload = struct { |
| 4506 | 4528 | tag: Tag, |