aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-22 15:06:13 +0000
committer_ov4 <ov4@ov4.org>2026-10-22 15:21:11 +0000
commitfa83b7df5a0711bf5f4a5162cc33b0a4123a53c7 (patch)
treedcfd24756256fcef21c43f19aa6e914455435806 /doc
parent353c38e23108856daa2c5d0e86443ac5136dcaa7 (diff)
fix(arrays): reject inverted bounds and check array allocation
Constant inverted bounds are a compile error and other bounds are checked at run time. Allocation sizes use overflow-checked arithmetic, and a NULL malloc (including the BYVAL copy) reports that the array is too large. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/language/keyword/cpsc-keyword-declare.7.md2
1 files changed, 1 insertions, 1 deletions
diff --git a/doc/language/keyword/cpsc-keyword-declare.7.md b/doc/language/keyword/cpsc-keyword-declare.7.md
index 6138916..6860ff5 100644
--- a/doc/language/keyword/cpsc-keyword-declare.7.md
+++ b/doc/language/keyword/cpsc-keyword-declare.7.md
@@ -17,7 +17,7 @@ Declare one variable per statement. Built-in types are INTEGER (signed 64-bit),
C_INT, C_CHAR, C_STRING and C_DOUBLE are native C aliases for int, char, char* and double. C_TYPE can introduce aliases for other supported C base types and pointers. C values start with zero or null; assignment from pseudocode types requires an explicit cast. See [cpsc-keyword-c_type(7)](cpsc-keyword-c_type.7.md).
-ARRAY bounds are inclusive and may be expressions; multiple ranges create multiple dimensions. Access elements with `name[index, ...]`. Bounds are checked at run time; an invalid index throws an exception that TRY/CATCH can handle. Whole-array assignment is unsupported. Declare arrays before using them; arrays declared inside a control-flow block stay in that block.
+ARRAY bounds are inclusive and may be expressions; every dimension needs an upper bound that is at least the lower bound (constant bounds that are inverted are a compile error, other bounds a run-time error), and an array too large to allocate is a run-time error; multiple ranges create multiple dimensions. Access elements with `name[index, ...]`. Bounds are checked at run time; an invalid index throws an exception that TRY/CATCH can handle. Whole-array assignment is unsupported. Declare arrays before using them; arrays declared inside a control-flow block stay in that block.
For class variables, an optional argument list after the type supplies constructor arguments, such as `DECLARE Item : Counter(3)`. Declarations zero storage and automatically construct class fields and array elements before calling the outer constructor. See [cpsc-keyword-class(7)](cpsc-keyword-class.7.md) for construction and NEW rebinding rules.