aboutsummaryrefslogtreecommitdiff
path: root/AGENTS
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-22 15:32:49 +0000
committer_ov4 <ov4@ov4.org>2026-10-22 15:32:49 +0000
commit713a313b06256a13ddefa5e257e3b80f8aa808ba (patch)
tree0288e9e9e44b9765cf2285fa3adaf82963612180 /AGENTS
parent5a5a14be5e2683a42906da4b2ad19690e230c871 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'AGENTS')
-rw-r--r--AGENTS/CONVENTIONS/STRINGS.md10
1 files changed, 10 insertions, 0 deletions
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.