From f14b50d776ec743bd62fda22a9c154bba9588840 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 15:07:27 +0000 Subject: feat(codegen)!: reject implicit BOOLEAN, CHAR and INTEGER mixing Arithmetic and unary minus accept only INTEGER and REAL, AND/OR/NOT need BOOLEAN, comparisons need equal types (or INTEGER with REAL), and only INTEGER converts implicitly to REAL. Use ASC and CHR for characters. No existing test program relied on the now-illegal mixing, so none changed. Co-Authored-By: Claude Sonnet 5.5 --- AGENTS/CONVENTIONS/TYPES.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'AGENTS') diff --git a/AGENTS/CONVENTIONS/TYPES.md b/AGENTS/CONVENTIONS/TYPES.md index 664782e..1c0d548 100644 --- a/AGENTS/CONVENTIONS/TYPES.md +++ b/AGENTS/CONVENTIONS/TYPES.md @@ -25,6 +25,12 @@ Allocation sizes still use LLVM sizeof; native C type widths use build-compiler sizeof. C alias declarations precede casts using their names; the parser tracks declared type names to distinguish `(Type)operand` from `(expression)`. +**Builtin scalars are strictly typed.** `CodeGen::emitBinaryOp` (ExpressionGen.cc) +rejects arithmetic on BOOLEAN/CHAR, AND/OR on non-BOOLEAN, and comparisons between +different kinds (INTEGER with REAL is the only mixed pair); `emitCoercedExpr` allows +only INTEGER->REAL between the four builtin scalars. BOOLEAN (i1) and CHAR (i8) +compare unsigned. C scalars keep C semantics. + **User-kind typing is nominal, and checked upstream only.** Enum/Record/Pointer identity is case-insensitive name equality (`P1 = ^INTEGER` and `P2 = ^INTEGER` are incompatible; same-layout records too). Their LLVM representations are -- cgit v1.3.1-4-g156e