From fe70048b33baebdfbf7071059bd4742ec16ab408 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 15:17:31 +0000 Subject: fix(classes): defer NEW for DECLARE without a parameterless constructor A plain DECLARE, field or array element now calls NEW only when the class has a parameterless one; otherwise the zeroed object waits for x <- NEW C(...), as in guide section 10.2. DECLARE with parentheses still requires a matching constructor. Co-Authored-By: Claude Sonnet 5.5 --- AGENTS/PITFALLS/classes.md | 6 ++++-- AGENTS/SUBSYSTEMS/CLASS_LIFETIME.md | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'AGENTS') diff --git a/AGENTS/PITFALLS/classes.md b/AGENTS/PITFALLS/classes.md index 82415d7..ff61439 100644 --- a/AGENTS/PITFALLS/classes.md +++ b/AGENTS/PITFALLS/classes.md @@ -20,8 +20,10 @@ Part of the [pitfalls index](../PITFALLS.md). ## Construction - PROCEDURE NEW is an ordinary case-insensitive member, also called automatically - after zero initialization by DECLARE and assignment-only keyword NEW. Fields and - array elements recursively require parameterless construction before the outer NEW. + after zero initialization by assignment-only keyword NEW and by DECLARE with + parentheses. A plain DECLARE (and fields and array elements, constructed before the + outer NEW) calls NEW only when a parameterless NEW exists (`emitDefaultConstruct`); + otherwise the zeroed object waits for `x <- NEW C(...)` (guide 10.2). - Class variables and BYVAL class parameters use reference slots: keyword NEW rebinds them, while ordinary assignment copies into their current object. - Fields, array elements, BYREF, this and pointer dereferences receive a value copy diff --git a/AGENTS/SUBSYSTEMS/CLASS_LIFETIME.md b/AGENTS/SUBSYSTEMS/CLASS_LIFETIME.md index 3b9ec58..eb7f039 100644 --- a/AGENTS/SUBSYSTEMS/CLASS_LIFETIME.md +++ b/AGENTS/SUBSYSTEMS/CLASS_LIFETIME.md @@ -10,8 +10,10 @@ Part of the [subsystem notes](../SUBSYSTEMS.md). Builds on [classes](CLASSES.md) marshalling and exception-aware calls. - DECLARE zeroes its original storage on every execution; arrays loop over all flat elements and default-construct each one. -- Constructor argument lists are class-only, and field/array defaults require a - parameterless NEW. Explicit NEW method calls do not reconstruct fields. +- Constructor argument lists are class-only. Plain DECLARE, field and array defaults go + through `emitDefaultConstruct`, which calls NEW only when a parameterless one exists + (else the object stays zeroed with constructed fields; guide 10.2); DECLARE with + parentheses uses `emitConstruct`. Explicit NEW method calls do not reconstruct fields. - `SymbolInfo::IsReference` marks a pointer slot for declared class variables and BYVAL class parameters; `symbolAddress` loads their current object address for all value, lvalue, address-of, receiver and BYREF paths. Field aliases, this and BYREF -- cgit v1.3.1-4-g156e