From ba160f8cbf230645baa828a095f25108e075ba51 Mon Sep 17 00:00:00 2001 From: Bogdan Romanyuk Date: Sun, 1 Dec 2024 21:13:27 +0300 Subject: [PATCH 1/2] Implement all the undef checks and add test checks --- src/Sema.zig | 59 ++++++-- src/Value.zig | 132 +++++++++++++++++- .../arithmetic_operations_with_undefined.zig | 82 +++++++++++ .../compile_errors/exact division failure.zig | 2 +- 4 files changed, 262 insertions(+), 13 deletions(-) create mode 100644 test/cases/compile_errors/arithmetic_operations_with_undefined.zig diff --git a/src/Sema.zig b/src/Sema.zig index b99852fb0afd..04fd6b9202e6 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -14594,7 +14594,7 @@ fn zirShl( var i: usize = 0; while (i < rhs_ty.vectorLen(zcu)) : (i += 1) { const rhs_elem = try rhs_val.elemValue(pt, i); - if (rhs_elem.compareHetero(.gte, bit_value, zcu)) { + if (!rhs_elem.isUndef(zcu) and rhs_elem.compareHetero(.gte, bit_value, zcu)) { return sema.fail(block, rhs_src, "shift amount '{}' at index '{d}' is too large for operand type '{}'", .{ rhs_elem.fmtValueSema(pt, sema), i, @@ -14602,7 +14602,7 @@ fn zirShl( }); } } - } else if (rhs_val.compareHetero(.gte, bit_value, zcu)) { + } else if (!rhs_val.isUndef(zcu) and rhs_val.compareHetero(.gte, bit_value, zcu)) { return sema.fail(block, rhs_src, "shift amount '{}' is too large for operand type '{}'", .{ rhs_val.fmtValueSema(pt, sema), scalar_ty.fmt(pt), @@ -14613,14 +14613,14 @@ fn zirShl( var i: usize = 0; while (i < rhs_ty.vectorLen(zcu)) : (i += 1) { const rhs_elem = try rhs_val.elemValue(pt, i); - if (rhs_elem.compareHetero(.lt, try pt.intValue(scalar_rhs_ty, 0), zcu)) { + if (!rhs_elem.isUndef(zcu) and rhs_elem.compareHetero(.lt, try pt.intValue(scalar_rhs_ty, 0), zcu)) { return sema.fail(block, rhs_src, "shift by negative amount '{}' at index '{d}'", .{ rhs_elem.fmtValueSema(pt, sema), i, }); } } - } else if (rhs_val.compareHetero(.lt, try pt.intValue(rhs_ty, 0), zcu)) { + } else if (!rhs_val.isUndef(zcu) and rhs_val.compareHetero(.lt, try pt.intValue(rhs_ty, 0), zcu)) { return sema.fail(block, rhs_src, "shift by negative amount '{}'", .{ rhs_val.fmtValueSema(pt, sema), }); @@ -14640,10 +14640,25 @@ fn zirShl( else switch (air_tag) { .shl_exact => val: { const shifted = try lhs_val.shlWithOverflow(rhs_val, lhs_ty, sema.arena, pt); - if (shifted.overflow_bit.compareAllWithZero(.eq, zcu)) { + if (lhs_ty.zigTypeTag(zcu) == .vector) { + const elems = zcu.intern_pool.indexToKey(shifted.overflow_bit.toIntern()).aggregate.storage.values(); + for (elems) |elem| { + const needed_value = Value.fromInterned(elem); + const not_undefined = !needed_value.isUndef(zcu); + if (not_undefined) { + const not_equal_to_zero = (try needed_value.orderAgainstZeroSema(pt)) != .eq; + if (not_equal_to_zero) { + return sema.fail(block, src, "operation caused overflow", .{}); + } + } + } break :val shifted.wrapped_result; + } else { + if (shifted.overflow_bit.compareAllWithZero(.eq, zcu)) { + break :val shifted.wrapped_result; + } + return sema.fail(block, src, "operation caused overflow", .{}); } - return sema.fail(block, src, "operation caused overflow", .{}); }, .shl_sat => try lhs_val.shlSat(rhs_val, lhs_ty, sema.arena, pt), .shl => try lhs_val.shlTrunc(rhs_val, lhs_ty, sema.arena, pt), @@ -14760,7 +14775,7 @@ fn zirShr( var i: usize = 0; while (i < rhs_ty.vectorLen(zcu)) : (i += 1) { const rhs_elem = try rhs_val.elemValue(pt, i); - if (rhs_elem.compareHetero(.gte, bit_value, zcu)) { + if (!rhs_elem.isUndef(zcu) and rhs_elem.compareHetero(.gte, bit_value, zcu)) { return sema.fail(block, rhs_src, "shift amount '{}' at index '{d}' is too large for operand type '{}'", .{ rhs_elem.fmtValueSema(pt, sema), i, @@ -14779,7 +14794,7 @@ fn zirShr( var i: usize = 0; while (i < rhs_ty.vectorLen(zcu)) : (i += 1) { const rhs_elem = try rhs_val.elemValue(pt, i); - if (rhs_elem.compareHetero(.lt, try pt.intValue(rhs_ty.childType(zcu), 0), zcu)) { + if (!rhs_elem.isUndef(zcu) and rhs_elem.compareHetero(.lt, try pt.intValue(rhs_ty.childType(zcu), 0), zcu)) { return sema.fail(block, rhs_src, "shift by negative amount '{}' at index '{d}'", .{ rhs_elem.fmtValueSema(pt, sema), i, @@ -14798,7 +14813,19 @@ fn zirShr( if (air_tag == .shr_exact) { // Detect if any ones would be shifted out. const truncated = try lhs_val.intTruncBitsAsValue(lhs_ty, sema.arena, .unsigned, rhs_val, pt); - if (!(try truncated.compareAllWithZeroSema(.eq, pt))) { + if (lhs_ty.zigTypeTag(zcu) == .vector and !truncated.isUndef(zcu)) { + const elems = zcu.intern_pool.indexToKey(truncated.toIntern()).aggregate.storage.values(); + for (elems) |elem| { + const needed_value = Value.fromInterned(elem); + const not_undefined = !needed_value.isUndef(zcu); + if (not_undefined) { + const not_equal_to_zero = (try needed_value.orderAgainstZeroSema(pt)) != .eq; + if (not_equal_to_zero) { + return sema.fail(block, src, "exact shift shifted out 1 bits", .{}); + } + } + } + } else if (!((try truncated.compareAllWithZeroSema(.eq, pt)) or truncated.isUndef(zcu))) { return sema.fail(block, src, "exact shift shifted out 1 bits", .{}); } } @@ -16515,6 +16542,12 @@ fn intRem( fn intRemScalar(sema: *Sema, lhs: Value, rhs: Value, scalar_ty: Type) CompileError!Value { const pt = sema.pt; + const zcu = pt.zcu; + + if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) { + return try pt.undefValue(scalar_ty); + } + // TODO is this a performance issue? maybe we should try the operation without // resorting to BigInt first. var lhs_space: Value.BigIntSpace = undefined; @@ -24286,8 +24319,12 @@ fn zirBitCount( const scalar_ty = operand_ty.scalarType(zcu); for (elems, 0..) |*elem, i| { const elem_val = try val.elemValue(pt, i); - const count = comptimeOp(elem_val, scalar_ty, zcu); - elem.* = (try pt.intValue(result_scalar_ty, count)).toIntern(); + if (elem_val.isUndef(zcu)) { + elem.* = (try pt.undefValue(result_scalar_ty)).toIntern(); + } else { + const count = comptimeOp(elem_val, scalar_ty, zcu); + elem.* = (try pt.intValue(result_scalar_ty, count)).toIntern(); + } } return Air.internedToRef((try pt.intern(.{ .aggregate = .{ .ty = result_ty.toIntern(), diff --git a/src/Value.zig b/src/Value.zig index dd27aaced22b..72ad9c9f5974 100644 --- a/src/Value.zig +++ b/src/Value.zig @@ -953,6 +953,11 @@ pub fn popCount(val: Value, ty: Type, zcu: *Zcu) u64 { pub fn bitReverse(val: Value, ty: Type, pt: Zcu.PerThread, arena: Allocator) !Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(ty); + } + const info = ty.intInfo(zcu); var buffer: Value.BigIntSpace = undefined; @@ -970,6 +975,11 @@ pub fn bitReverse(val: Value, ty: Type, pt: Zcu.PerThread, arena: Allocator) !Va pub fn byteSwap(val: Value, ty: Type, pt: Zcu.PerThread, arena: Allocator) !Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(ty); + } + const info = ty.intInfo(zcu); // Bit count must be evenly divisible by 8 @@ -2185,6 +2195,11 @@ pub fn intDivScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: // TODO is this a performance issue? maybe we should try the operation without // resorting to BigInt first. const zcu = pt.zcu; + + if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) { + return try pt.undefValue(ty); + } + var lhs_space: Value.BigIntSpace = undefined; var rhs_space: Value.BigIntSpace = undefined; const lhs_bigint = lhs.toBigInt(&lhs_space, zcu); @@ -2234,6 +2249,11 @@ pub fn intDivFloorScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, // TODO is this a performance issue? maybe we should try the operation without // resorting to BigInt first. const zcu = pt.zcu; + + if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) { + return try pt.undefValue(ty); + } + var lhs_space: Value.BigIntSpace = undefined; var rhs_space: Value.BigIntSpace = undefined; const lhs_bigint = lhs.toBigInt(&lhs_space, zcu); @@ -2277,6 +2297,11 @@ pub fn intModScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: // TODO is this a performance issue? maybe we should try the operation without // resorting to BigInt first. const zcu = pt.zcu; + + if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) { + return try pt.undefValue(ty); + } + var lhs_space: Value.BigIntSpace = undefined; var rhs_space: Value.BigIntSpace = undefined; const lhs_bigint = lhs.toBigInt(&lhs_space, zcu); @@ -2381,6 +2406,11 @@ pub fn floatMod(lhs: Value, rhs: Value, float_type: Type, arena: Allocator, pt: pub fn floatModScalar(lhs: Value, rhs: Value, float_type: Type, pt: Zcu.PerThread) !Value { const zcu = pt.zcu; + + if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @mod(lhs.toFloat(f16, zcu), rhs.toFloat(f16, zcu)) }, @@ -2503,6 +2533,9 @@ pub fn intTruncBitsAsValue( for (result_data, 0..) |*scalar, i| { const elem_val = try val.elemValue(pt, i); const bits_elem = try bits.elemValue(pt, i); + if (bits_elem.isUndef(zcu)) { + return try pt.undefValue(ty); + } scalar.* = (try intTruncScalar(elem_val, scalar_ty, allocator, signedness, @intCast(bits_elem.toUnsignedInt(zcu)), pt)).toIntern(); } return Value.fromInterned(try pt.intern(.{ .aggregate = .{ @@ -2524,7 +2557,9 @@ pub fn intTruncScalar( const zcu = pt.zcu; if (bits == 0) return pt.intValue(ty, 0); - if (val.isUndef(zcu)) return pt.undefValue(ty); + if (val.isUndef(zcu)) { + return try pt.undefValue(ty); + } var val_space: Value.BigIntSpace = undefined; const val_bigint = val.toBigInt(&val_space, zcu); @@ -2561,6 +2596,11 @@ pub fn shlScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu // TODO is this a performance issue? maybe we should try the operation without // resorting to BigInt first. const zcu = pt.zcu; + + if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) { + return try pt.undefValue(ty); + } + var lhs_space: Value.BigIntSpace = undefined; const lhs_bigint = lhs.toBigInt(&lhs_space, zcu); const shift: usize = @intCast(rhs.toUnsignedInt(zcu)); @@ -2624,6 +2664,13 @@ pub fn shlWithOverflowScalar( ) !OverflowArithmeticResult { const zcu = pt.zcu; const info = ty.intInfo(zcu); + + if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) + return OverflowArithmeticResult{ + .overflow_bit = try pt.undefValue(Type.u1), + .wrapped_result = try pt.undefValue(ty), + }; + var lhs_space: Value.BigIntSpace = undefined; const lhs_bigint = lhs.toBigInt(&lhs_space, zcu); const shift: usize = @intCast(rhs.toUnsignedInt(zcu)); @@ -2682,6 +2729,9 @@ pub fn shlSatScalar( const zcu = pt.zcu; const info = ty.intInfo(zcu); + if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) + return try pt.undefValue(ty); + var lhs_space: Value.BigIntSpace = undefined; const lhs_bigint = lhs.toBigInt(&lhs_space, zcu); const shift: usize = @intCast(rhs.toUnsignedInt(zcu)); @@ -2755,6 +2805,11 @@ pub fn shrScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu // TODO is this a performance issue? maybe we should try the operation without // resorting to BigInt first. const zcu = pt.zcu; + + if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) { + return try pt.undefValue(ty); + } + var lhs_space: Value.BigIntSpace = undefined; const lhs_bigint = lhs.toBigInt(&lhs_space, zcu); const shift: usize = @intCast(rhs.toUnsignedInt(zcu)); @@ -3113,6 +3168,11 @@ pub fn sqrt(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) ! pub fn sqrtScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @sqrt(val.toFloat(f16, zcu)) }, @@ -3147,6 +3207,11 @@ pub fn sin(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !V pub fn sinScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @sin(val.toFloat(f16, zcu)) }, @@ -3181,6 +3246,11 @@ pub fn cos(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !V pub fn cosScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @cos(val.toFloat(f16, zcu)) }, @@ -3215,6 +3285,11 @@ pub fn tan(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !V pub fn tanScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @tan(val.toFloat(f16, zcu)) }, @@ -3249,6 +3324,11 @@ pub fn exp(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !V pub fn expScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @exp(val.toFloat(f16, zcu)) }, @@ -3283,6 +3363,11 @@ pub fn exp2(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) ! pub fn exp2Scalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @exp2(val.toFloat(f16, zcu)) }, @@ -3317,6 +3402,11 @@ pub fn log(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !V pub fn logScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @log(val.toFloat(f16, zcu)) }, @@ -3351,6 +3441,11 @@ pub fn log2(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) ! pub fn log2Scalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @log2(val.toFloat(f16, zcu)) }, @@ -3385,6 +3480,11 @@ pub fn log10(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) pub fn log10Scalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @log10(val.toFloat(f16, zcu)) }, @@ -3419,6 +3519,11 @@ pub fn abs(val: Value, ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value { pub fn absScalar(val: Value, ty: Type, pt: Zcu.PerThread, arena: Allocator) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(ty); + } + switch (ty.zigTypeTag(zcu)) { .int => { var buffer: Value.BigIntSpace = undefined; @@ -3472,6 +3577,11 @@ pub fn floor(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) pub fn floorScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @floor(val.toFloat(f16, zcu)) }, @@ -3506,6 +3616,11 @@ pub fn ceil(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) ! pub fn ceilScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @ceil(val.toFloat(f16, zcu)) }, @@ -3540,6 +3655,11 @@ pub fn round(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) pub fn roundScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @round(val.toFloat(f16, zcu)) }, @@ -3574,6 +3694,11 @@ pub fn trunc(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) pub fn truncScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Error!Value { const zcu = pt.zcu; + + if (val.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @trunc(val.toFloat(f16, zcu)) }, @@ -3623,6 +3748,11 @@ pub fn mulAddScalar( pt: Zcu.PerThread, ) Allocator.Error!Value { const zcu = pt.zcu; + + if (mulend1.isUndef(zcu) or mulend2.isUndef(zcu) or addend.isUndef(zcu)) { + return try pt.undefValue(float_type); + } + const target = zcu.getTarget(); const storage: InternPool.Key.Float.Storage = switch (float_type.floatBits(target)) { 16 => .{ .f16 = @mulAdd(f16, mulend1.toFloat(f16, zcu), mulend2.toFloat(f16, zcu), addend.toFloat(f16, zcu)) }, diff --git a/test/cases/compile_errors/arithmetic_operations_with_undefined.zig b/test/cases/compile_errors/arithmetic_operations_with_undefined.zig new file mode 100644 index 000000000000..7fcf362c0199 --- /dev/null +++ b/test/cases/compile_errors/arithmetic_operations_with_undefined.zig @@ -0,0 +1,82 @@ +const U8Vec = @Vector(3, u8); +const FloatVec = @Vector(1, f32); + +comptime { + const a: U8Vec = .{ undefined, 0, undefined }; + const b: U8Vec = @splat(1); + const c: FloatVec = .{undefined}; + @compileLog(a >> b); + @compileLog(b >> a); + @compileLog(a << b); + @compileLog(b << a); + @compileLog(@shlExact(a, b)); + @compileLog(@shlExact(b, a)); + @compileLog(@shlWithOverflow(a, b)); + @compileLog(@shlWithOverflow(b, a)); + @compileLog(@shrExact(a, b)); + @compileLog(@shrExact(b, a)); + @compileLog(@subWithOverflow(a, b)); + @compileLog(@sin(c)); + @compileLog(@cos(c)); + @compileLog(@tan(c)); + @compileLog(@exp(c)); + @compileLog(@exp2(c)); + @compileLog(@log(c)); + @compileLog(@log2(c)); + @compileLog(@log10(c)); + @compileLog(@abs(a)); + @compileLog(@abs(c)); + @compileLog(@floor(c)); + @compileLog(@ceil(c)); + @compileLog(@round(c)); + @compileLog(@trunc(c)); + @compileLog(@mod(a, b)); + @compileLog(@rem(a, b)); + @compileLog(@mulAdd(FloatVec, c, c, c)); + @compileLog(@byteSwap(a)); + @compileLog(@bitReverse(a)); + @compileLog(@clz(a)); + @compileLog(@ctz(a)); + @compileLog(@popCount(a)); +} + +// error +// backend=stage2 +// target=native +// +// :8:5: error: found compile log statement +// +// Compile Log Output: +// @as(@Vector(3, u8), .{ undefined, 0, undefined }) +// @as(@Vector(3, u8), .{ undefined, 1, undefined }) +// @as(@Vector(3, u8), .{ undefined, 0, undefined }) +// @as(@Vector(3, u8), .{ undefined, 1, undefined }) +// @as(@Vector(3, u8), .{ undefined, 0, undefined }) +// @as(@Vector(3, u8), .{ undefined, 1, undefined }) +// @as(struct { @Vector(3, u8), @Vector(3, u1) }, .{ .{ undefined, 0, undefined }, .{ undefined, 0, undefined } }) +// @as(struct { @Vector(3, u8), @Vector(3, u1) }, .{ .{ undefined, 1, undefined }, .{ undefined, 0, undefined } }) +// @as(@Vector(3, u8), .{ undefined, 0, undefined }) +// @as(@Vector(3, u8), .{ undefined, 1, undefined }) +// @as(struct { @Vector(3, u8), @Vector(3, u1) }, .{ .{ undefined, 255, undefined }, .{ undefined, 1, undefined } }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(3, u8), .{ undefined, 0, undefined }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(3, u8), .{ undefined, 0, undefined }) +// @as(@Vector(3, u8), .{ undefined, 0, undefined }) +// @as(@Vector(1, f32), .{ undefined }) +// @as(@Vector(3, u8), .{ undefined, 0, undefined }) +// @as(@Vector(3, u8), .{ undefined, 0, undefined }) +// @as(@Vector(3, u4), .{ undefined, 8, undefined }) +// @as(@Vector(3, u4), .{ undefined, 8, undefined }) +// @as(@Vector(3, u4), .{ undefined, 0, undefined }) diff --git a/test/cases/compile_errors/exact division failure.zig b/test/cases/compile_errors/exact division failure.zig index d134e0e2fbab..b5a4ed2f5e1d 100644 --- a/test/cases/compile_errors/exact division failure.zig +++ b/test/cases/compile_errors/exact division failure.zig @@ -1,6 +1,6 @@ comptime { const x = @divExact(10, 3); - _ = x; + _ = &x; } // error From 13cda45d60904c0e4a40863bdcad7ed2ab3dbd6b Mon Sep 17 00:00:00 2001 From: Bogdan Romanyuk Date: Sun, 2 Feb 2025 20:49:40 +0300 Subject: [PATCH 2/2] adjust struct name --- test/cases/compile_errors/redundant_try.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cases/compile_errors/redundant_try.zig b/test/cases/compile_errors/redundant_try.zig index 22dabb1bdbd6..7d02bbd96711 100644 --- a/test/cases/compile_errors/redundant_try.zig +++ b/test/cases/compile_errors/redundant_try.zig @@ -44,9 +44,9 @@ comptime { // // :5:23: error: expected error union type, found 'comptime_int' // :10:23: error: expected error union type, found '@TypeOf(.{})' -// :15:23: error: expected error union type, found 'tmp.test2__struct_493' +// :15:23: error: expected error union type, found 'tmp.test2__struct_494' // :15:23: note: struct declared here -// :20:27: error: expected error union type, found 'tmp.test3__struct_495' +// :20:27: error: expected error union type, found 'tmp.test3__struct_496' // :20:27: note: struct declared here // :25:23: error: expected error union type, found 'struct { comptime *const [5:0]u8 = "hello" }' // :31:13: error: expected error union type, found 'u32'