diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-22 15:17:31 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-22 15:21:11 +0000 |
| commit | fe70048b33baebdfbf7071059bd4742ec16ab408 (patch) | |
| tree | 040ab1e1d6847baf8b60b8c1970543b8e578e36f /AGENTS/PITFALLS/classes.md | |
| parent | 98ef8bc4dfcebe44eece933ff0affc776b7199dd (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'AGENTS/PITFALLS/classes.md')
| -rw-r--r-- | AGENTS/PITFALLS/classes.md | 6 |
1 files changed, 4 insertions, 2 deletions
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 |
