| author | |
| committer | |
| log | 8878f085dccaf9efe89a04b458205fddc215e095 |
| tree | be49e3d222c1e58d4f962f155d24a197c8bd4778 |
| parent | f6aaab9406807305c2b48fcd742449c9e91f1851 |
This makes formatted printing work when mixing comptime and runtime
fields.3 files changed, 7 insertions(+), 5 deletions(-)
src/Sema.zig+3-2| ... | ... | @@ -19585,8 +19585,9 @@ fn typeRequiresComptime(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) C |
| 19585 | 19585 | |
| 19586 | 19586 | .tuple => { |
| 19587 | 19587 | const tuple = ty.castTag(.tuple).?.data; |
| 19588 | for (tuple.types) |field_ty| { | |
| 19589 | if (try sema.typeRequiresComptime(block, src, field_ty)) { | |
| 19588 | for (tuple.types) |field_ty, i| { | |
| 19589 | const have_comptime_val = tuple.values[i].tag() != .unreachable_value; | |
| 19590 | if (!have_comptime_val and try sema.typeRequiresComptime(block, src, field_ty)) { | |
| 19590 | 19591 | return true; |
| 19591 | 19592 | } |
| 19592 | 19593 | } |
src/type.zig+3-2| ... | ... | @@ -4050,8 +4050,9 @@ pub const Type = extern union { |
| 4050 | 4050 | |
| 4051 | 4051 | .tuple => { |
| 4052 | 4052 | const tuple = ty.castTag(.tuple).?.data; |
| 4053 | for (tuple.types) |field_ty| { | |
| 4054 | if (field_ty.comptimeOnly()) return true; | |
| 4053 | for (tuple.types) |field_ty, i| { | |
| 4054 | const have_comptime_val = tuple.values[i].tag() != .unreachable_value; | |
| 4055 | if (!have_comptime_val and field_ty.comptimeOnly()) return true; | |
| 4055 | 4056 | } |
| 4056 | 4057 | return false; |
| 4057 | 4058 | }, |
test/behavior/tuple.zig+1-1| ... | ... | @@ -45,7 +45,7 @@ test "tuple multiplication" { |
| 45 | 45 | comptime try S.doTheTest(); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | test "tuple concatenation" { | |
| 48 | test "more tuple concatenation" { | |
| 49 | 49 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO |
| 50 | 50 | |
| 51 | 51 | const T = struct { |