| author | |
| committer | |
| log | 213c4fc25f214a0d8763bd7976db9ae3eec0f232 |
| tree | 5ceaf1f1947006bac5ab6c43edd9f876c4ff8127 |
| parent | d764716cb5cdcf3dec07d66ce87be915327f564e |
| signature |
In preparation for its removal, as accepted in
https://github.com/ziglang/zig/issues/1593.22 files changed, 29 insertions(+), 128 deletions(-)
lib/std/Io/Reader.zig-5| ... | @@ -2097,7 +2097,6 @@ test "deserialize signed LEB128" { | ... | @@ -2097,7 +2097,6 @@ test "deserialize signed LEB128" { |
| 2097 | try testing.expectEqual(std.math.minInt(i128), testLeb128(i128, "\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x7E")); | 2097 | try testing.expectEqual(std.math.minInt(i128), testLeb128(i128, "\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x7E")); |
| 2098 | 2098 | ||
| 2099 | // Specific cases | 2099 | // Specific cases |
| 2100 | try testing.expectEqual(0, testLeb128(i0, "\x00")); | ||
| 2101 | try testing.expectEqual(0, testLeb128(i2, "\x00")); | 2100 | try testing.expectEqual(0, testLeb128(i2, "\x00")); |
| 2102 | try testing.expectEqual(0, testLeb128(i8, "\x00")); | 2101 | try testing.expectEqual(0, testLeb128(i8, "\x00")); |
| 2103 | 2102 | ||
| ... | @@ -2134,8 +2133,6 @@ test "deserialize signed LEB128" { | ... | @@ -2134,8 +2133,6 @@ test "deserialize signed LEB128" { |
| 2134 | try testing.expectError(error.EndOfStream, testLeb128(i128, &end_of_stream)); | 2133 | try testing.expectError(error.EndOfStream, testLeb128(i128, &end_of_stream)); |
| 2135 | 2134 | ||
| 2136 | // Overflow | 2135 | // Overflow |
| 2137 | try testing.expectError(error.Overflow, testLeb128(i0, "\x01")); | ||
| 2138 | try testing.expectError(error.Overflow, testLeb128(i0, "\x7F")); | ||
| 2139 | try testing.expectError(error.Overflow, testLeb128(i8, "\x80\x01")); | 2136 | try testing.expectError(error.Overflow, testLeb128(i8, "\x80\x01")); |
| 2140 | try testing.expectError(error.Overflow, testLeb128(i8, "\xFF\x7E")); | 2137 | try testing.expectError(error.Overflow, testLeb128(i8, "\xFF\x7E")); |
| 2141 | try testing.expectError(error.Overflow, testLeb128(i8, "\x80\x80\x40")); | 2138 | try testing.expectError(error.Overflow, testLeb128(i8, "\x80\x80\x40")); |
| ... | @@ -2145,7 +2142,6 @@ test "deserialize signed LEB128" { | ... | @@ -2145,7 +2142,6 @@ test "deserialize signed LEB128" { |
| 2145 | try testing.expectError(error.Overflow, testLeb128(i64, "\x80\x80\x80\x80\x80\x80\x80\x80\x80\x01")); | 2142 | try testing.expectError(error.Overflow, testLeb128(i64, "\x80\x80\x80\x80\x80\x80\x80\x80\x80\x01")); |
| 2146 | try testing.expectError(error.Overflow, testLeb128(i64, "\x80\x80\x80\x80\x80\x80\x80\x80\x80\x40")); | 2143 | try testing.expectError(error.Overflow, testLeb128(i64, "\x80\x80\x80\x80\x80\x80\x80\x80\x80\x40")); |
| 2147 | 2144 | ||
| 2148 | try testing.expectError(error.Overflow, testLeb128(i0, &overflow)); | ||
| 2149 | try testing.expectError(error.Overflow, testLeb128(i7, &overflow)); | 2145 | try testing.expectError(error.Overflow, testLeb128(i7, &overflow)); |
| 2150 | try testing.expectError(error.Overflow, testLeb128(i8, &overflow)); | 2146 | try testing.expectError(error.Overflow, testLeb128(i8, &overflow)); |
| 2151 | try testing.expectError(error.Overflow, testLeb128(i14, &overflow)); | 2147 | try testing.expectError(error.Overflow, testLeb128(i14, &overflow)); |
| ... | @@ -2159,7 +2155,6 @@ test "deserialize signed LEB128" { | ... | @@ -2159,7 +2155,6 @@ test "deserialize signed LEB128" { |
| 2159 | try testing.expectEqual(0x80, testLeb128(i64, "\x80\x81\x00")); | 2155 | try testing.expectEqual(0x80, testLeb128(i64, "\x80\x81\x00")); |
| 2160 | try testing.expectEqual(0x80, testLeb128(i64, "\x80\x81\x80\x00")); | 2156 | try testing.expectEqual(0x80, testLeb128(i64, "\x80\x81\x80\x00")); |
| 2161 | 2157 | ||
| 2162 | try testing.expectEqual(0, testLeb128(i0, &long_zero)); | ||
| 2163 | try testing.expectEqual(0, testLeb128(i7, &long_zero)); | 2158 | try testing.expectEqual(0, testLeb128(i7, &long_zero)); |
| 2164 | try testing.expectEqual(0, testLeb128(i8, &long_zero)); | 2159 | try testing.expectEqual(0, testLeb128(i8, &long_zero)); |
| 2165 | try testing.expectEqual(0, testLeb128(i14, &long_zero)); | 2160 | try testing.expectEqual(0, testLeb128(i14, &long_zero)); |
lib/std/Io/Writer.zig-1| ... | @@ -1924,7 +1924,6 @@ test "serialize signed LEB128" { | ... | @@ -1924,7 +1924,6 @@ test "serialize signed LEB128" { |
| 1924 | try testLeb128Encoding(i128, std.math.minInt(i128), "\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x7E"); | 1924 | try testLeb128Encoding(i128, std.math.minInt(i128), "\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x7E"); |
| 1925 | 1925 | ||
| 1926 | // Specific cases | 1926 | // Specific cases |
| 1927 | try testLeb128Encoding(i0, 0, "\x00"); | ||
| 1928 | try testLeb128Encoding(i8, 0, "\x00"); | 1927 | try testLeb128Encoding(i8, 0, "\x00"); |
| 1929 | 1928 | ||
| 1930 | try testLeb128Encoding(i2, -1, "\x7F"); | 1929 | try testLeb128Encoding(i2, -1, "\x7F"); |
lib/std/json/static_test.zig-7| ... | @@ -22,7 +22,6 @@ const Primitives = struct { | ... | @@ -22,7 +22,6 @@ const Primitives = struct { |
| 22 | f32: f32, | 22 | f32: f32, |
| 23 | f64: f64, | 23 | f64: f64, |
| 24 | u0: u0, | 24 | u0: u0, |
| 25 | i0: i0, | ||
| 26 | u1: u1, | 25 | u1: u1, |
| 27 | i1: i1, | 26 | i1: i1, |
| 28 | u8: u8, | 27 | u8: u8, |
| ... | @@ -35,7 +34,6 @@ const primitives_0 = Primitives{ | ... | @@ -35,7 +34,6 @@ const primitives_0 = Primitives{ |
| 35 | .f32 = 0, | 34 | .f32 = 0, |
| 36 | .f64 = 0, | 35 | .f64 = 0, |
| 37 | .u0 = 0, | 36 | .u0 = 0, |
| 38 | .i0 = 0, | ||
| 39 | .u1 = 0, | 37 | .u1 = 0, |
| 40 | .i1 = 0, | 38 | .i1 = 0, |
| 41 | .u8 = 0, | 39 | .u8 = 0, |
| ... | @@ -48,7 +46,6 @@ const primitives_0_doc_0 = | ... | @@ -48,7 +46,6 @@ const primitives_0_doc_0 = |
| 48 | \\ "f32": 0, | 46 | \\ "f32": 0, |
| 49 | \\ "f64": 0, | 47 | \\ "f64": 0, |
| 50 | \\ "u0": 0, | 48 | \\ "u0": 0, |
| 51 | \\ "i0": 0, | ||
| 52 | \\ "u1": 0, | 49 | \\ "u1": 0, |
| 53 | \\ "i1": 0, | 50 | \\ "i1": 0, |
| 54 | \\ "u8": 0, | 51 | \\ "u8": 0, |
| ... | @@ -62,7 +59,6 @@ const primitives_0_doc_1 = // looks like a float. | ... | @@ -62,7 +59,6 @@ const primitives_0_doc_1 = // looks like a float. |
| 62 | \\ "f32": 0.0, | 59 | \\ "f32": 0.0, |
| 63 | \\ "f64": 0.0, | 60 | \\ "f64": 0.0, |
| 64 | \\ "u0": 0.0, | 61 | \\ "u0": 0.0, |
| 65 | \\ "i0": 0.0, | ||
| 66 | \\ "u1": 0.0, | 62 | \\ "u1": 0.0, |
| 67 | \\ "i1": 0.0, | 63 | \\ "i1": 0.0, |
| 68 | \\ "u8": 0.0, | 64 | \\ "u8": 0.0, |
| ... | @@ -76,7 +72,6 @@ const primitives_1 = Primitives{ | ... | @@ -76,7 +72,6 @@ const primitives_1 = Primitives{ |
| 76 | .f32 = 1073741824, | 72 | .f32 = 1073741824, |
| 77 | .f64 = 1152921504606846976, | 73 | .f64 = 1152921504606846976, |
| 78 | .u0 = 0, | 74 | .u0 = 0, |
| 79 | .i0 = 0, | ||
| 80 | .u1 = 1, | 75 | .u1 = 1, |
| 81 | .i1 = -1, | 76 | .i1 = -1, |
| 82 | .u8 = 255, | 77 | .u8 = 255, |
| ... | @@ -89,7 +84,6 @@ const primitives_1_doc_0 = | ... | @@ -89,7 +84,6 @@ const primitives_1_doc_0 = |
| 89 | \\ "f32": 1073741824, | 84 | \\ "f32": 1073741824, |
| 90 | \\ "f64": 1152921504606846976, | 85 | \\ "f64": 1152921504606846976, |
| 91 | \\ "u0": 0, | 86 | \\ "u0": 0, |
| 92 | \\ "i0": 0, | ||
| 93 | \\ "u1": 1, | 87 | \\ "u1": 1, |
| 94 | \\ "i1": -1, | 88 | \\ "i1": -1, |
| 95 | \\ "u8": 255, | 89 | \\ "u8": 255, |
| ... | @@ -103,7 +97,6 @@ const primitives_1_doc_1 = // float rounding. | ... | @@ -103,7 +97,6 @@ const primitives_1_doc_1 = // float rounding. |
| 103 | \\ "f32": 1073741825, | 97 | \\ "f32": 1073741825, |
| 104 | \\ "f64": 1152921504606846977, | 98 | \\ "f64": 1152921504606846977, |
| 105 | \\ "u0": 0, | 99 | \\ "u0": 0, |
| 106 | \\ "i0": 0, | ||
| 107 | \\ "u1": 1, | 100 | \\ "u1": 1, |
| 108 | \\ "i1": -1, | 101 | \\ "i1": -1, |
| 109 | \\ "u8": 255, | 102 | \\ "u8": 255, |
lib/std/math.zig+12-18| ... | @@ -1141,13 +1141,11 @@ test isPowerOfTwo { | ... | @@ -1141,13 +1141,11 @@ test isPowerOfTwo { |
| 1141 | pub fn ByteAlignedInt(comptime T: type) type { | 1141 | pub fn ByteAlignedInt(comptime T: type) type { |
| 1142 | const info = @typeInfo(T).int; | 1142 | const info = @typeInfo(T).int; |
| 1143 | const bits = (info.bits + 7) / 8 * 8; | 1143 | const bits = (info.bits + 7) / 8 * 8; |
| 1144 | const extended_type = std.meta.Int(info.signedness, bits); | 1144 | return @Int(info.signedness, bits); |
| 1145 | return extended_type; | ||
| 1146 | } | 1145 | } |
| 1147 | 1146 | ||
| 1148 | test ByteAlignedInt { | 1147 | test ByteAlignedInt { |
| 1149 | try testing.expect(ByteAlignedInt(u0) == u0); | 1148 | try testing.expect(ByteAlignedInt(u0) == u0); |
| 1150 | try testing.expect(ByteAlignedInt(i0) == i0); | ||
| 1151 | try testing.expect(ByteAlignedInt(u3) == u8); | 1149 | try testing.expect(ByteAlignedInt(u3) == u8); |
| 1152 | try testing.expect(ByteAlignedInt(u8) == u8); | 1150 | try testing.expect(ByteAlignedInt(u8) == u8); |
| 1153 | try testing.expect(ByteAlignedInt(i111) == i112); | 1151 | try testing.expect(ByteAlignedInt(i111) == i112); |
| ... | @@ -1218,7 +1216,7 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo( | ... | @@ -1218,7 +1216,7 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo( |
| 1218 | comptime assert(@typeInfo(T) == .int); | 1216 | comptime assert(@typeInfo(T) == .int); |
| 1219 | comptime assert(@typeInfo(T).int.signedness == .unsigned); | 1217 | comptime assert(@typeInfo(T).int.signedness == .unsigned); |
| 1220 | assert(value != 0); | 1218 | assert(value != 0); |
| 1221 | const PromotedType = std.meta.Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1); | 1219 | const PromotedType = @Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1); |
| 1222 | const ShiftType = std.math.Log2Int(PromotedType); | 1220 | const ShiftType = std.math.Log2Int(PromotedType); |
| 1223 | return @as(PromotedType, 1) << @as(ShiftType, @intCast(@typeInfo(T).int.bits - @clz(value - 1))); | 1221 | return @as(PromotedType, 1) << @as(ShiftType, @intCast(@typeInfo(T).int.bits - @clz(value - 1))); |
| 1224 | } | 1222 | } |
| ... | @@ -1230,7 +1228,7 @@ pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) { | ... | @@ -1230,7 +1228,7 @@ pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) { |
| 1230 | comptime assert(@typeInfo(T) == .int); | 1228 | comptime assert(@typeInfo(T) == .int); |
| 1231 | const info = @typeInfo(T).int; | 1229 | const info = @typeInfo(T).int; |
| 1232 | comptime assert(info.signedness == .unsigned); | 1230 | comptime assert(info.signedness == .unsigned); |
| 1233 | const PromotedType = std.meta.Int(info.signedness, info.bits + 1); | 1231 | const PromotedType = @Int(info.signedness, info.bits + 1); |
| 1234 | const overflowBit = @as(PromotedType, 1) << info.bits; | 1232 | const overflowBit = @as(PromotedType, 1) << info.bits; |
| 1235 | const x = ceilPowerOfTwoPromote(T, value); | 1233 | const x = ceilPowerOfTwoPromote(T, value); |
| 1236 | if (overflowBit & x != 0) { | 1234 | if (overflowBit & x != 0) { |
| ... | @@ -1442,19 +1440,17 @@ test lerp { | ... | @@ -1442,19 +1440,17 @@ test lerp { |
| 1442 | 1440 | ||
| 1443 | /// Returns the maximum value of integer type T. | 1441 | /// Returns the maximum value of integer type T. |
| 1444 | pub fn maxInt(comptime T: type) comptime_int { | 1442 | pub fn maxInt(comptime T: type) comptime_int { |
| 1445 | const info = @typeInfo(T); | 1443 | const info = @typeInfo(T).int; |
| 1446 | const bit_count = info.int.bits; | 1444 | return (1 << (info.bits - @intFromBool(info.signedness == .signed))) - 1; |
| 1447 | if (bit_count == 0) return 0; | ||
| 1448 | return (1 << (bit_count - @intFromBool(info.int.signedness == .signed))) - 1; | ||
| 1449 | } | 1445 | } |
| 1450 | 1446 | ||
| 1451 | /// Returns the minimum value of integer type T. | 1447 | /// Returns the minimum value of integer type T. |
| 1452 | pub fn minInt(comptime T: type) comptime_int { | 1448 | pub fn minInt(comptime T: type) comptime_int { |
| 1453 | const info = @typeInfo(T); | 1449 | const info = @typeInfo(T).int; |
| 1454 | const bit_count = info.int.bits; | 1450 | return switch (info.signedness) { |
| 1455 | if (info.int.signedness == .unsigned) return 0; | 1451 | .unsigned => 0, |
| 1456 | if (bit_count == 0) return 0; | 1452 | .signed => -(1 << (info.bits - 1)), |
| 1457 | return -(1 << (bit_count - 1)); | 1453 | }; |
| 1458 | } | 1454 | } |
| 1459 | 1455 | ||
| 1460 | test maxInt { | 1456 | test maxInt { |
| ... | @@ -1466,7 +1462,6 @@ test maxInt { | ... | @@ -1466,7 +1462,6 @@ test maxInt { |
| 1466 | try testing.expect(maxInt(u64) == 18446744073709551615); | 1462 | try testing.expect(maxInt(u64) == 18446744073709551615); |
| 1467 | try testing.expect(maxInt(u128) == 340282366920938463463374607431768211455); | 1463 | try testing.expect(maxInt(u128) == 340282366920938463463374607431768211455); |
| 1468 | 1464 | ||
| 1469 | try testing.expect(maxInt(i0) == 0); | ||
| 1470 | try testing.expect(maxInt(i1) == 0); | 1465 | try testing.expect(maxInt(i1) == 0); |
| 1471 | try testing.expect(maxInt(i8) == 127); | 1466 | try testing.expect(maxInt(i8) == 127); |
| 1472 | try testing.expect(maxInt(i16) == 32767); | 1467 | try testing.expect(maxInt(i16) == 32767); |
| ... | @@ -1486,7 +1481,6 @@ test minInt { | ... | @@ -1486,7 +1481,6 @@ test minInt { |
| 1486 | try testing.expect(minInt(u64) == 0); | 1481 | try testing.expect(minInt(u64) == 0); |
| 1487 | try testing.expect(minInt(u128) == 0); | 1482 | try testing.expect(minInt(u128) == 0); |
| 1488 | 1483 | ||
| 1489 | try testing.expect(minInt(i0) == 0); | ||
| 1490 | try testing.expect(minInt(i1) == -1); | 1484 | try testing.expect(minInt(i1) == -1); |
| 1491 | try testing.expect(minInt(i8) == -128); | 1485 | try testing.expect(minInt(i8) == -128); |
| 1492 | try testing.expect(minInt(i16) == -32768); | 1486 | try testing.expect(minInt(i16) == -32768); |
| ... | @@ -1710,8 +1704,8 @@ pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt { | ... | @@ -1710,8 +1704,8 @@ pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt { |
| 1710 | if (@typeInfo(MaskInt) != .int) | 1704 | if (@typeInfo(MaskInt) != .int) |
| 1711 | @compileError("boolMask requires an integer mask type."); | 1705 | @compileError("boolMask requires an integer mask type."); |
| 1712 | 1706 | ||
| 1713 | if (MaskInt == u0 or MaskInt == i0) | 1707 | if (MaskInt == u0) |
| 1714 | @compileError("boolMask cannot convert to u0 or i0, they are too small."); | 1708 | @compileError("boolMask cannot convert to u0, it is too small."); |
| 1715 | 1709 | ||
| 1716 | // The u1 and i1 cases tend to overflow, | 1710 | // The u1 and i1 cases tend to overflow, |
| 1717 | // so we special case them here. | 1711 | // so we special case them here. |
lib/std/math/big/int_test.zig-3| ... | @@ -602,7 +602,6 @@ test "bitcount/to" { | ... | @@ -602,7 +602,6 @@ test "bitcount/to" { |
| 602 | try testing.expectEqual(0, a.bitCountTwosComp()); | 602 | try testing.expectEqual(0, a.bitCountTwosComp()); |
| 603 | 603 | ||
| 604 | try testing.expectEqual(0, try a.toInt(u0)); | 604 | try testing.expectEqual(0, try a.toInt(u0)); |
| 605 | try testing.expectEqual(0, try a.toInt(i0)); | ||
| 606 | 605 | ||
| 607 | try a.set(-1); | 606 | try a.set(-1); |
| 608 | try testing.expectEqual(1, a.bitCountTwosComp()); | 607 | try testing.expectEqual(1, a.bitCountTwosComp()); |
| ... | @@ -631,7 +630,6 @@ test "fits" { | ... | @@ -631,7 +630,6 @@ test "fits" { |
| 631 | 630 | ||
| 632 | try a.set(0); | 631 | try a.set(0); |
| 633 | try testing.expect(a.fits(u0)); | 632 | try testing.expect(a.fits(u0)); |
| 634 | try testing.expect(a.fits(i0)); | ||
| 635 | 633 | ||
| 636 | try a.set(255); | 634 | try a.set(255); |
| 637 | try testing.expect(!a.fits(u0)); | 635 | try testing.expect(!a.fits(u0)); |
| ... | @@ -711,7 +709,6 @@ test "twos complement limit set" { | ... | @@ -711,7 +709,6 @@ test "twos complement limit set" { |
| 711 | try testTwosComplementLimit(u1); | 709 | try testTwosComplementLimit(u1); |
| 712 | try testTwosComplementLimit(i1); | 710 | try testTwosComplementLimit(i1); |
| 713 | try testTwosComplementLimit(u0); | 711 | try testTwosComplementLimit(u0); |
| 714 | try testTwosComplementLimit(i0); | ||
| 715 | try testTwosComplementLimit(u65); | 712 | try testTwosComplementLimit(u65); |
| 716 | try testTwosComplementLimit(i65); | 713 | try testTwosComplementLimit(i65); |
| 717 | } | 714 | } |
lib/std/math/nextafter.zig+1-2| ... | @@ -23,7 +23,7 @@ pub fn nextAfter(comptime T: type, x: T, y: T) T { | ... | @@ -23,7 +23,7 @@ pub fn nextAfter(comptime T: type, x: T, y: T) T { |
| 23 | fn nextAfterInt(comptime T: type, x: T, y: T) T { | 23 | fn nextAfterInt(comptime T: type, x: T, y: T) T { |
| 24 | comptime assert(@typeInfo(T) == .int or @typeInfo(T) == .comptime_int); | 24 | comptime assert(@typeInfo(T) == .int or @typeInfo(T) == .comptime_int); |
| 25 | return if (@typeInfo(T) == .int and @bitSizeOf(T) < 2) | 25 | return if (@typeInfo(T) == .int and @bitSizeOf(T) < 2) |
| 26 | // Special case for `i0`, `u0`, `i1`, and `u1`. | 26 | // Special case for `u0`, `i1`, and `u1`. |
| 27 | y | 27 | y |
| 28 | else if (y > x) | 28 | else if (y > x) |
| 29 | x + 1 | 29 | x + 1 |
| ... | @@ -102,7 +102,6 @@ fn nextAfterFloat(comptime T: type, x: T, y: T) T { | ... | @@ -102,7 +102,6 @@ fn nextAfterFloat(comptime T: type, x: T, y: T) T { |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | test "int" { | 104 | test "int" { |
| 105 | try expect(nextAfter(i0, 0, 0) == 0); | ||
| 106 | try expect(nextAfter(u0, 0, 0) == 0); | 105 | try expect(nextAfter(u0, 0, 0) == 0); |
| 107 | try expect(nextAfter(i1, 0, 0) == 0); | 106 | try expect(nextAfter(i1, 0, 0) == 0); |
| 108 | try expect(nextAfter(i1, 0, -1) == -1); | 107 | try expect(nextAfter(i1, 0, -1) == -1); |
lib/std/math/powi.zig+2-3| ... | @@ -15,12 +15,12 @@ const testing = std.testing; | ... | @@ -15,12 +15,12 @@ const testing = std.testing; |
| 15 | /// - Underflow: Absolute value of result smaller than 1 | 15 | /// - Underflow: Absolute value of result smaller than 1 |
| 16 | /// | 16 | /// |
| 17 | /// Edge case rules ordered by precedence: | 17 | /// Edge case rules ordered by precedence: |
| 18 | /// - powi(T, x, 0) = 1 unless T is i1, i0, u0 | 18 | /// - powi(T, x, 0) = 1 unless T is i1, u0 |
| 19 | /// - powi(T, 0, x) = 0 when x > 0 | 19 | /// - powi(T, 0, x) = 0 when x > 0 |
| 20 | /// - powi(T, 0, x) = Overflow | 20 | /// - powi(T, 0, x) = Overflow |
| 21 | /// - powi(T, 1, y) = 1 | 21 | /// - powi(T, 1, y) = 1 |
| 22 | /// - powi(T, -1, y) = -1 for y an odd integer | 22 | /// - powi(T, -1, y) = -1 for y an odd integer |
| 23 | /// - powi(T, -1, y) = 1 unless T is i1, i0, u0 | 23 | /// - powi(T, -1, y) = 1 unless T is i1, u0 |
| 24 | /// - powi(T, -1, y) = Overflow | 24 | /// - powi(T, -1, y) = Overflow |
| 25 | /// - powi(T, x, y) = Overflow when y >= @bitSizeOf(x) | 25 | /// - powi(T, x, y) = Overflow when y >= @bitSizeOf(x) |
| 26 | /// - powi(T, x, y) = Underflow when y < 0 | 26 | /// - powi(T, x, y) = Underflow when y < 0 |
| ... | @@ -189,7 +189,6 @@ test "powi.special" { | ... | @@ -189,7 +189,6 @@ test "powi.special" { |
| 189 | 189 | ||
| 190 | test "powi.narrow" { | 190 | test "powi.narrow" { |
| 191 | try testing.expectError(error.Overflow, powi(u0, 0, 0)); | 191 | try testing.expectError(error.Overflow, powi(u0, 0, 0)); |
| 192 | try testing.expectError(error.Overflow, powi(i0, 0, 0)); | ||
| 193 | try testing.expectError(error.Overflow, powi(i1, 0, 0)); | 192 | try testing.expectError(error.Overflow, powi(i1, 0, 0)); |
| 194 | try testing.expectError(error.Overflow, powi(i1, -1, 0)); | 193 | try testing.expectError(error.Overflow, powi(i1, -1, 0)); |
| 195 | try testing.expectError(error.Overflow, powi(i1, 0, -1)); | 194 | try testing.expectError(error.Overflow, powi(i1, 0, -1)); |
lib/std/math/signbit.zig-1| ... | @@ -13,7 +13,6 @@ pub fn signbit(x: anytype) bool { | ... | @@ -13,7 +13,6 @@ pub fn signbit(x: anytype) bool { |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | test signbit { | 15 | test signbit { |
| 16 | try testInts(i0); | ||
| 17 | try testInts(u0); | 16 | try testInts(u0); |
| 18 | try testInts(i1); | 17 | try testInts(i1); |
| 19 | try testInts(u1); | 18 | try testInts(u1); |
lib/std/mem.zig-2| ... | @@ -370,7 +370,6 @@ test zeroes { | ... | @@ -370,7 +370,6 @@ test zeroes { |
| 370 | comptime comptime_field: u8 = 5, | 370 | comptime comptime_field: u8 = 5, |
| 371 | 371 | ||
| 372 | integral_types: struct { | 372 | integral_types: struct { |
| 373 | integer_0: i0, | ||
| 374 | integer_8: i8, | 373 | integer_8: i8, |
| 375 | integer_16: i16, | 374 | integer_16: i16, |
| 376 | integer_32: i32, | 375 | integer_32: i32, |
| ... | @@ -405,7 +404,6 @@ test zeroes { | ... | @@ -405,7 +404,6 @@ test zeroes { |
| 405 | 404 | ||
| 406 | const b = zeroes(ZigStruct); | 405 | const b = zeroes(ZigStruct); |
| 407 | try testing.expectEqual(@as(u8, 5), b.comptime_field); | 406 | try testing.expectEqual(@as(u8, 5), b.comptime_field); |
| 408 | try testing.expectEqual(@as(i8, 0), b.integral_types.integer_0); | ||
| 409 | try testing.expectEqual(@as(i8, 0), b.integral_types.integer_8); | 407 | try testing.expectEqual(@as(i8, 0), b.integral_types.integer_8); |
| 410 | try testing.expectEqual(@as(i16, 0), b.integral_types.integer_16); | 408 | try testing.expectEqual(@as(i16, 0), b.integral_types.integer_16); |
| 411 | try testing.expectEqual(@as(i32, 0), b.integral_types.integer_32); | 409 | try testing.expectEqual(@as(i32, 0), b.integral_types.integer_32); |
lib/std/meta.zig+1-1| ... | @@ -1067,7 +1067,7 @@ test hasUniqueRepresentation { | ... | @@ -1067,7 +1067,7 @@ test hasUniqueRepresentation { |
| 1067 | 1067 | ||
| 1068 | try testing.expect(!hasUniqueRepresentation(TestUnion4)); | 1068 | try testing.expect(!hasUniqueRepresentation(TestUnion4)); |
| 1069 | 1069 | ||
| 1070 | inline for ([_]type{ i0, u8, i16, u32, i64 }) |T| { | 1070 | inline for ([_]type{ u8, i16, u32, i64 }) |T| { |
| 1071 | try testing.expect(hasUniqueRepresentation(T)); | 1071 | try testing.expect(hasUniqueRepresentation(T)); |
| 1072 | try testing.expect(hasUniqueRepresentation(enum(T) { _ })); | 1072 | try testing.expect(hasUniqueRepresentation(enum(T) { _ })); |
| 1073 | } | 1073 | } |
test/behavior/atomics.zig-1| ... | @@ -369,7 +369,6 @@ test "atomics with different types" { | ... | @@ -369,7 +369,6 @@ test "atomics with different types" { |
| 369 | try testAtomicsWithType(u24, 2, 1); | 369 | try testAtomicsWithType(u24, 2, 1); |
| 370 | 370 | ||
| 371 | try testAtomicsWithType(u0, 0, 0); | 371 | try testAtomicsWithType(u0, 0, 0); |
| 372 | try testAtomicsWithType(i0, 0, 0); | ||
| 373 | 372 | ||
| 374 | try testAtomicsWithType(enum(u32) { x = 1234, y = 5678 }, .x, .y); | 373 | try testAtomicsWithType(enum(u32) { x = 1234, y = 5678 }, .x, .y); |
| 375 | try testAtomicsWithType(enum(u19) { x = 1234, y = 5678 }, .x, .y); | 374 | try testAtomicsWithType(enum(u19) { x = 1234, y = 5678 }, .x, .y); |
test/behavior/cast.zig-3| ... | @@ -3079,8 +3079,6 @@ test "@intFromFloat boundary cases" { | ... | @@ -3079,8 +3079,6 @@ test "@intFromFloat boundary cases" { |
| 3079 | 3079 | ||
| 3080 | try case(u0, 1.0, .down, 0); | 3080 | try case(u0, 1.0, .down, 0); |
| 3081 | try case(u0, -1.0, .up, 0); | 3081 | try case(u0, -1.0, .up, 0); |
| 3082 | try case(i0, 1.0, .down, 0); | ||
| 3083 | try case(i0, -1.0, .up, 0); | ||
| 3084 | 3082 | ||
| 3085 | try case(u10, 1024.0, .down, 1023); | 3083 | try case(u10, 1024.0, .down, 1023); |
| 3086 | try case(u10, -1.0, .up, 0); | 3084 | try case(u10, -1.0, .up, 0); |
| ... | @@ -3111,7 +3109,6 @@ test "@intFromFloat vector boundary cases" { | ... | @@ -3111,7 +3109,6 @@ test "@intFromFloat vector boundary cases" { |
| 3111 | try case(i8, .{ -129.0, 128.0 }, .{ -128, 127 }); | 3109 | try case(i8, .{ -129.0, 128.0 }, .{ -128, 127 }); |
| 3112 | 3110 | ||
| 3113 | try case(u0, .{ -1.0, 1.0 }, .{ 0, 0 }); | 3111 | try case(u0, .{ -1.0, 1.0 }, .{ 0, 0 }); |
| 3114 | try case(i0, .{ -1.0, 1.0 }, .{ 0, 0 }); | ||
| 3115 | 3112 | ||
| 3116 | try case(u10, .{ -1.0, 1024.0 }, .{ 0, 1023 }); | 3113 | try case(u10, .{ -1.0, 1024.0 }, .{ 0, 1023 }); |
| 3117 | try case(i10, .{ -513.0, 512.0 }, .{ -512, 511 }); | 3114 | try case(i10, .{ -513.0, 512.0 }, .{ -512, 511 }); |
test/behavior/field_parent_ptr.zig+5-5| ... | @@ -1903,7 +1903,7 @@ test "@fieldParentPtr tagged union all zero-bit fields" { | ... | @@ -1903,7 +1903,7 @@ test "@fieldParentPtr tagged union all zero-bit fields" { |
| 1903 | 1903 | ||
| 1904 | const C = union(enum) { | 1904 | const C = union(enum) { |
| 1905 | a: u0, | 1905 | a: u0, |
| 1906 | b: i0, | 1906 | b: void, |
| 1907 | }; | 1907 | }; |
| 1908 | 1908 | ||
| 1909 | { | 1909 | { |
| ... | @@ -1938,20 +1938,20 @@ test "@fieldParentPtr tagged union all zero-bit fields" { | ... | @@ -1938,20 +1938,20 @@ test "@fieldParentPtr tagged union all zero-bit fields" { |
| 1938 | } | 1938 | } |
| 1939 | 1939 | ||
| 1940 | { | 1940 | { |
| 1941 | const c: C = .{ .b = 0 }; | 1941 | const c: C = .{ .b = {} }; |
| 1942 | const pcf = &c.b; | 1942 | const pcf = &c.b; |
| 1943 | const pc: *const C = @alignCast(@fieldParentPtr("b", pcf)); | 1943 | const pc: *const C = @alignCast(@fieldParentPtr("b", pcf)); |
| 1944 | try expect(pc == &c); | 1944 | try expect(pc == &c); |
| 1945 | } | 1945 | } |
| 1946 | { | 1946 | { |
| 1947 | const c: C = .{ .b = 0 }; | 1947 | const c: C = .{ .b = {} }; |
| 1948 | const pcf = &c.b; | 1948 | const pcf = &c.b; |
| 1949 | var pc: *const C = undefined; | 1949 | var pc: *const C = undefined; |
| 1950 | pc = @alignCast(@fieldParentPtr("b", pcf)); | 1950 | pc = @alignCast(@fieldParentPtr("b", pcf)); |
| 1951 | try expect(pc == &c); | 1951 | try expect(pc == &c); |
| 1952 | } | 1952 | } |
| 1953 | { | 1953 | { |
| 1954 | const c: C = .{ .b = 0 }; | 1954 | const c: C = .{ .b = {} }; |
| 1955 | var pcf: @TypeOf(&c.b) = undefined; | 1955 | var pcf: @TypeOf(&c.b) = undefined; |
| 1956 | pcf = &c.b; | 1956 | pcf = &c.b; |
| 1957 | var pc: *const C = undefined; | 1957 | var pc: *const C = undefined; |
| ... | @@ -1960,7 +1960,7 @@ test "@fieldParentPtr tagged union all zero-bit fields" { | ... | @@ -1960,7 +1960,7 @@ test "@fieldParentPtr tagged union all zero-bit fields" { |
| 1960 | } | 1960 | } |
| 1961 | { | 1961 | { |
| 1962 | var c: C = undefined; | 1962 | var c: C = undefined; |
| 1963 | c = .{ .b = 0 }; | 1963 | c = .{ .b = {} }; |
| 1964 | var pcf: @TypeOf(&c.b) = undefined; | 1964 | var pcf: @TypeOf(&c.b) = undefined; |
| 1965 | pcf = &c.b; | 1965 | pcf = &c.b; |
| 1966 | var pc: *C = undefined; | 1966 | var pc: *C = undefined; |
test/behavior/int_comparison_elision.zig-1| ... | @@ -7,7 +7,6 @@ test "int comparison elision" { | ... | @@ -7,7 +7,6 @@ test "int comparison elision" { |
| 7 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; | 7 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 8 | 8 | ||
| 9 | testIntEdges(u0); | 9 | testIntEdges(u0); |
| 10 | testIntEdges(i0); | ||
| 11 | testIntEdges(u1); | 10 | testIntEdges(u1); |
| 12 | testIntEdges(i1); | 11 | testIntEdges(i1); |
| 13 | testIntEdges(u4); | 12 | testIntEdges(u4); |
test/behavior/math.zig-1| ... | @@ -401,7 +401,6 @@ test "binary not" { | ... | @@ -401,7 +401,6 @@ test "binary not" { |
| 401 | try expect(not(u64, 0x0123_4567_89AB_CDEF) == 0xFEDC_BA98_7654_3210); | 401 | try expect(not(u64, 0x0123_4567_89AB_CDEF) == 0xFEDC_BA98_7654_3210); |
| 402 | try expect(not(u64, 0xFEDC_BA98_7654_3210) == 0x0123_4567_89AB_CDEF); | 402 | try expect(not(u64, 0xFEDC_BA98_7654_3210) == 0x0123_4567_89AB_CDEF); |
| 403 | 403 | ||
| 404 | try expect(not(i0, 0) == 0); | ||
| 405 | try expect(not(i1, 0) == -1); | 404 | try expect(not(i1, 0) == -1); |
| 406 | try expect(not(i1, -1) == 0); | 405 | try expect(not(i1, -1) == 0); |
| 407 | try expect(not(i5, -2) == 1); | 406 | try expect(not(i5, -2) == 1); |
test/behavior/switch_loop.zig+2-2| ... | @@ -547,12 +547,12 @@ test "switch loop with packed unions" { | ... | @@ -547,12 +547,12 @@ test "switch loop with packed unions" { |
| 547 | test "switch loop with packed unions with OPV" { | 547 | test "switch loop with packed unions with OPV" { |
| 548 | const P = packed union { | 548 | const P = packed union { |
| 549 | a: u0, | 549 | a: u0, |
| 550 | b: i0, | 550 | b: void, |
| 551 | 551 | ||
| 552 | fn doTheTest(p: @This()) !void { | 552 | fn doTheTest(p: @This()) !void { |
| 553 | var looped = false; | 553 | var looped = false; |
| 554 | s: switch (p) { | 554 | s: switch (p) { |
| 555 | .{ .b = 0 } => |x| { | 555 | .{ .b = {} } => |x| { |
| 556 | comptime assert(x.a == 0); | 556 | comptime assert(x.a == 0); |
| 557 | if (looped) break :s; | 557 | if (looped) break :s; |
| 558 | looped = true; | 558 | looped = true; |
test/behavior/truncate.zig-25| ... | @@ -31,31 +31,6 @@ test "truncate.u0.var" { | ... | @@ -31,31 +31,6 @@ test "truncate.u0.var" { |
| 31 | try expect(z == 0); | 31 | try expect(z == 0); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | test "truncate i0 to larger integer allowed and has comptime-known result" { | ||
| 35 | var x: i0 = 0; | ||
| 36 | _ = &x; | ||
| 37 | const y: i8 = @truncate(x); | ||
| 38 | comptime assert(y == 0); | ||
| 39 | } | ||
| 40 | |||
| 41 | test "truncate.i0.literal" { | ||
| 42 | const z: i0 = @truncate(0); | ||
| 43 | try expect(z == 0); | ||
| 44 | } | ||
| 45 | |||
| 46 | test "truncate.i0.const" { | ||
| 47 | const c0: isize = 0; | ||
| 48 | const z: i0 = @truncate(c0); | ||
| 49 | try expect(z == 0); | ||
| 50 | } | ||
| 51 | |||
| 52 | test "truncate.i0.var" { | ||
| 53 | var d: i8 = 2; | ||
| 54 | _ = &d; | ||
| 55 | const z: i0 = @truncate(d); | ||
| 56 | try expect(z == 0); | ||
| 57 | } | ||
| 58 | |||
| 59 | test "truncate on comptime integer" { | 34 | test "truncate on comptime integer" { |
| 60 | const x: u16 = @truncate(9999); | 35 | const x: u16 = @truncate(9999); |
| 61 | try expect(x == 9999); | 36 | try expect(x == 9999); |
test/cases/compile_errors/leading_zero_in_integer.zig+5-6| ... | @@ -3,7 +3,6 @@ export fn entry1() void { | ... | @@ -3,7 +3,6 @@ export fn entry1() void { |
| 3 | _ = T; | 3 | _ = T; |
| 4 | } | 4 | } |
| 5 | export fn entry2() void { | 5 | export fn entry2() void { |
| 6 | _ = i0; | ||
| 7 | _ = u0; | 6 | _ = u0; |
| 8 | var x: i01 = 1; | 7 | var x: i01 = 1; |
| 9 | _ = x; | 8 | _ = x; |
| ... | @@ -18,8 +17,8 @@ export fn entry4() void { | ... | @@ -18,8 +17,8 @@ export fn entry4() void { |
| 18 | // error | 17 | // error |
| 19 | // | 18 | // |
| 20 | // :2:15: error: primitive integer type 'u000123' has leading zero | 19 | // :2:15: error: primitive integer type 'u000123' has leading zero |
| 21 | // :8:12: error: primitive integer type 'i01' has leading zero | 20 | // :7:12: error: primitive integer type 'i01' has leading zero |
| 22 | // :12:9: error: number '000123' has leading zero | 21 | // :11:9: error: number '000123' has leading zero |
| 23 | // :12:9: note: use '0o' prefix for octal literals | 22 | // :11:9: note: use '0o' prefix for octal literals |
| 24 | // :15:9: error: number '01' has leading zero | 23 | // :14:9: error: number '01' has leading zero |
| 25 | // :15:9: note: use '0o' prefix for octal literals | 24 | // :14:9: note: use '0o' prefix for octal literals |
test/cases/compile_errors/zero_width_nonexhaustive_enum.zig+1-7| ... | @@ -1,8 +1,3 @@ | ... | @@ -1,8 +1,3 @@ |
| 1 | comptime { | ||
| 2 | const E = enum(i0) { a, _ }; | ||
| 3 | _ = @as(E, undefined); | ||
| 4 | } | ||
| 5 | |||
| 6 | comptime { | 1 | comptime { |
| 7 | const E = enum(u0) { a, _ }; | 2 | const E = enum(u0) { a, _ }; |
| 8 | _ = @as(E, undefined); | 3 | _ = @as(E, undefined); |
| ... | @@ -16,5 +11,4 @@ comptime { | ... | @@ -16,5 +11,4 @@ comptime { |
| 16 | // error | 11 | // error |
| 17 | // | 12 | // |
| 18 | // :2:15: error: non-exhaustive enum specifies every value | 13 | // :2:15: error: non-exhaustive enum specifies every value |
| 19 | // :7:15: error: non-exhaustive enum specifies every value | 14 | // :7:29: error: enum tag value '1' too large for type 'u0' |
| 20 | // :12:29: error: enum tag value '1' too large for type 'u0' |
test/cases/safety/@intFromFloat cannot fit - boundary case - i0 max.zig	 deleted-16| ... | @@ -1,16 +0,0 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { | ||
| 3 | _ = stack_trace; | ||
| 4 | if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) { | ||
| 5 | std.process.exit(0); | ||
| 6 | } | ||
| 7 | std.process.exit(1); | ||
| 8 | } | ||
| 9 | var x: f32 = 1.0; | ||
| 10 | pub fn main() !void { | ||
| 11 | _ = @as(i0, @intFromFloat(x)); | ||
| 12 | return error.TestFailed; | ||
| 13 | } | ||
| 14 | // run | ||
| 15 | // backend=selfhosted,llvm | ||
| 16 | // target=x86_64-linux,aarch64-linux | ||
test/cases/safety/@intFromFloat cannot fit - boundary case - i0 min.zig	 deleted-16| ... | @@ -1,16 +0,0 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { | ||
| 3 | _ = stack_trace; | ||
| 4 | if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) { | ||
| 5 | std.process.exit(0); | ||
| 6 | } | ||
| 7 | std.process.exit(1); | ||
| 8 | } | ||
| 9 | var x: f32 = -1.0; | ||
| 10 | pub fn main() !void { | ||
| 11 | _ = @as(i0, @intFromFloat(x)); | ||
| 12 | return error.TestFailed; | ||
| 13 | } | ||
| 14 | // run | ||
| 15 | // backend=selfhosted,llvm | ||
| 16 | // target=x86_64-linux,aarch64-linux | ||
test/src/Debugger.zig-2| ... | @@ -56,7 +56,6 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void { | ... | @@ -56,7 +56,6 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void { |
| 56 | \\ u24_16777215: u24 = 16777215, | 56 | \\ u24_16777215: u24 = 16777215, |
| 57 | \\ u32_0: u32 = 0, | 57 | \\ u32_0: u32 = 0, |
| 58 | \\ u32_4294967295: u32 = 4294967295, | 58 | \\ u32_4294967295: u32 = 4294967295, |
| 59 | \\ i0_0: i0 = 0, | ||
| 60 | \\ @"i1_-1": i1 = -1, | 59 | \\ @"i1_-1": i1 = -1, |
| 61 | \\ i1_0: i1 = 0, | 60 | \\ i1_0: i1 = 0, |
| 62 | \\ @"i2_-2": i2 = -2, | 61 | \\ @"i2_-2": i2 = -2, |
| ... | @@ -139,7 +138,6 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void { | ... | @@ -139,7 +138,6 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void { |
| 139 | \\ (u24) .u24_16777215 = 16777215 | 138 | \\ (u24) .u24_16777215 = 16777215 |
| 140 | \\ (u32) .u32_0 = 0 | 139 | \\ (u32) .u32_0 = 0 |
| 141 | \\ (u32) .u32_4294967295 = 4294967295 | 140 | \\ (u32) .u32_4294967295 = 4294967295 |
| 142 | \\ (i0) .i0_0 = 0 | ||
| 143 | \\ (i1) .@"i1_-1" = -1 | 141 | \\ (i1) .@"i1_-1" = -1 |
| 144 | \\ (i1) .i1_0 = 0 | 142 | \\ (i1) .i1_0 = 0 |
| 145 | \\ (i2) .@"i2_-2" = -2 | 143 | \\ (i2) .@"i2_-2" = -2 |