| author | |
| committer | |
| log | f2814caaf04fc041a028d5ede4fb4db5ee2f19ae |
| tree | 50dfaa41d3118225cf1d3da6b31d637e657792bf |
| parent | 67caf685056bcdbbe4e696cada927615b0dd6fe9 |
| signature |
This logic is not correct in most cases. If any instruction needs to
operate with different semantics within `@TypeOf`, it should be made to
do so explicitly.
This broke a line in `std.mem`: I have opted to fix this in std for now,
since as far as I know it's not yet been discussed which operations (if
any) should be special-cased like this within `@TypeOf`.2 files changed, 7 insertions(+), 2 deletions(-)
lib/std/mem.zig+7-1| ... | ... | @@ -3666,7 +3666,13 @@ fn ReverseIterator(comptime T: type) type { |
| 3666 | 3666 | @compileError("expected slice or pointer to array, found '" ++ @typeName(T) ++ "'"); |
| 3667 | 3667 | }; |
| 3668 | 3668 | const Element = std.meta.Elem(Pointer); |
| 3669 | const ElementPointer = @TypeOf(&@as(Pointer, undefined)[0]); | |
| 3669 | const ElementPointer = @Type(.{ .Pointer = ptr: { | |
| 3670 | var ptr = @typeInfo(Pointer).Pointer; | |
| 3671 | ptr.size = .One; | |
| 3672 | ptr.child = Element; | |
| 3673 | ptr.sentinel = null; | |
| 3674 | break :ptr ptr; | |
| 3675 | } }); | |
| 3670 | 3676 | return struct { |
| 3671 | 3677 | ptr: Pointer, |
| 3672 | 3678 | index: usize, |
src/Sema.zig-1| ... | ... | @@ -2104,7 +2104,6 @@ fn resolveDefinedValue( |
| 2104 | 2104 | const mod = sema.mod; |
| 2105 | 2105 | const val = try sema.resolveValue(air_ref) orelse return null; |
| 2106 | 2106 | if (val.isUndef(mod)) { |
| 2107 | if (block.is_typeof) return null; | |
| 2108 | 2107 | return sema.failWithUseOfUndef(block, src); |
| 2109 | 2108 | } |
| 2110 | 2109 | return val; |