mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-26 13:01:34 +03:00
Merge pull request 'Sema: Support peer type resolution for floats and small integers' (#30921) from jayschwa/zig:ptr-small-int-and-floats into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30921 Reviewed-by: Andrew Kelley <andrew@ziglang.org>
This commit is contained in:
@@ -10,6 +10,17 @@ test "peer resolve int widening" {
|
||||
try expectEqual(i16, @TypeOf(c));
|
||||
}
|
||||
|
||||
test "peer resolve small int and float" {
|
||||
// This only works for integer types that can coerce to the float type.
|
||||
// Larger integer types will cause a compiler error; no float widening occurs.
|
||||
var i: u8 = 12;
|
||||
var f: f32 = 34;
|
||||
_ = .{ &i, &f };
|
||||
const x = i + f;
|
||||
try expectEqual(x, 46.0);
|
||||
try expectEqual(@TypeOf(x), f32);
|
||||
}
|
||||
|
||||
test "peer resolve arrays of different size to const slice" {
|
||||
try expectEqualStrings("true", boolToStr(true));
|
||||
try expectEqualStrings("false", boolToStr(false));
|
||||
|
||||
Reference in New Issue
Block a user