From 713a313b06256a13ddefa5e257e3b80f8aa808ba Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 15:32:49 +0000 Subject: feat(codegen): convert implicitly between CHAR and STRING A CHAR becomes a one-character STRING in &, comparisons, assignment, parameter passing and RETURN. A STRING becomes a CHAR in assignment, parameter passing and RETURN, with a runtime error when its length is not 1. CHAR with INTEGER or BOOLEAN still does not convert. Co-Authored-By: Claude Sonnet 5.5 --- AGENTS/CONVENTIONS/STRINGS.md | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'AGENTS') diff --git a/AGENTS/CONVENTIONS/STRINGS.md b/AGENTS/CONVENTIONS/STRINGS.md index 2908167..9bb81cf 100644 --- a/AGENTS/CONVENTIONS/STRINGS.md +++ b/AGENTS/CONVENTIONS/STRINGS.md @@ -11,6 +11,16 @@ are ordinary library definitions, with exact overload selection. Comparisons use case-sensitive byte ordering. A missing STRING class or required bridge method is a compile error. +**CHAR and STRING convert implicitly.** `emitCoercedExpr` turns a CHAR into a +one-character STRING (`emitStringFromChar`, STRING.NEW(1, ch)) and a STRING into a CHAR +(`emitCharFromString`, via the `_LENGTH()` and `C_STR()` bridge methods), so assignment, +parameter passing and RETURN need no special cases; a length other than 1 is a runtime +error. `resolveOperator` and `resolveCall` fall back to the STRING overload when an +exact match is missing and a CHAR is involved (`'a' & 'b'`, `"a" = 'a'`); two CHAR +operands still compare as CHARs, and CASE converts the CHAR side itself. A converted +value is a fresh temporary, so `emitAssignment` copies its source (CopySource) only when +the source type equals the target type. CHAR with INTEGER or BOOLEAN never converts. + **Ownership follows value copies.** STRING constructors/assignment prevent shared handles. Records and BYVAL arrays containing STRING recursively copy their string-bearing fields/elements; RETURN and temporary cleanup preserve ownership. -- cgit v1.3.1-4-g156e