aboutsummaryrefslogtreecommitdiff
path: root/src/compiler/lex.zc
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 16:58:59 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 16:58:59 +0330
commit041c887fc081bbc9a40c3a7381866b9ff6902bc0 (patch)
tree3a1adbb1822a5230252fe603465d84159ac8bdc2 /src/compiler/lex.zc
parentas: the type after as is read greedily in both compilers; x as int * y is a s... (diff)
bool: normalising into a bool keeps an incompatible source type, so the return type check still fires (fixes typeerrors/ret.zc after b.2.6)
Diffstat (limited to 'src/compiler/lex.zc')
-rw-r--r--src/compiler/lex.zc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/compiler/lex.zc b/src/compiler/lex.zc
index 2763333..712eff8 100644
--- a/src/compiler/lex.zc
+++ b/src/compiler/lex.zc
@@ -301,7 +301,8 @@ int fcoerce(word dst) {
if (dst[0] == TY_BOOL && xty[0] != TY_BOOL) { // bool holds 0 or 1: any nonzero value is 1 (spec 2.1)
if (xfloat) { op(OP_FLIT); emit(0); op(OP_FEQ); lit(1); op(18); xfloat = 0; }
else { lit(0); op(O_PICK); lit(0); op(O_SWAP); op(O_SUB); op(17); lit(63); op(19); lit(0); op(O_SWAP); op(O_SUB); }
- xty = tbool; return 0;
+ if (compat(dst, xty)) xty = tbool; // (otherwise keep the type, so a type check after this still sees it)
+ return 0;
}
if (!xfloat) {
if (tbytes(dst) && !samesz(dst, xty)) tnorm(dst);