From 03978f333c775e118f6d93761c6d59c142eccbd6 Mon Sep 17 00:00:00 2001 From: dzaima Date: Sun, 6 Mar 2022 13:44:27 +0200 Subject: [PATCH] =?UTF-8?q?make=20=E2=80=A2bit.=5Fcast=20properly=20error?= =?UTF-8?q?=20on=20non-array=20=F0=9D=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/sysfn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index 5a4f5566..b8b0a579 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -984,10 +984,11 @@ static u8 typeOfCast(CastType t) { } } B bitcast_impl(B el0, B el1, B x) { - CastType xt = getCastType(el0, x); - CastType zt = getCastType(el1, bi_N); ur xr; if (!isArr(x) || (xr=rnk(x))<1) thrM("•bit._cast: 𝕩 must have rank at least 1"); + + CastType xt = getCastType(el0, x); + CastType zt = getCastType(el1, bi_N); usz* sh = a(x)->sh; usz s=xt.s*sh[xr-1], zl=s/zt.s; if (zl*zt.s != s) thrM("•bit._cast: incompatible lengths");