zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 77be7d36aa9e52a9fa045acf927b1d422c4e344b (tree)
parent 911f411886cd740db4939adb9eec05cffb655df0
Author: AdriĆ  Arrufat <adria.arrufat@gmail.com>
Date:   Fri, 20 Mar 2026 16:44:23 +0900

Sema: improve error for non-float operand in round cast

Diffstat:
Msrc/Sema.zig | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/Sema.zig b/src/Sema.zig @@ -20881,7 +20881,15 @@ fn zirRoundCast( const dest_scalar_ty = dest_ty.scalarType(zcu); const operand_scalar_ty = operand_ty.scalarType(zcu); - try sema.checkFloatType(block, operand_src, operand_scalar_ty); + switch (operand_scalar_ty.zigTypeTag(zcu)) { + .comptime_float, .float => {}, + else => return sema.fail( + block, + operand_src, + "expected float or vector type, found '{f}'", + .{operand_ty.fmt(pt)}, + ), + } switch (dest_scalar_ty.zigTypeTag(zcu)) { .float, .comptime_float => {