diff options
Diffstat (limited to 'AGENTS/PITFALLS')
| -rw-r--r-- | AGENTS/PITFALLS/core-language.md | 4 | ||||
| -rw-r--r-- | AGENTS/PITFALLS/overload-template-operator.md | 12 |
2 files changed, 11 insertions, 5 deletions
diff --git a/AGENTS/PITFALLS/core-language.md b/AGENTS/PITFALLS/core-language.md index 5018fb3..05793e7 100644 --- a/AGENTS/PITFALLS/core-language.md +++ b/AGENTS/PITFALLS/core-language.md @@ -32,8 +32,8 @@ source, most also by compiling and running test programs. - **`/` always yields REAL** (double FDiv), even for two INTEGERs; integer division is DIV/MOD only. - CHR returns CHAR, not STRING; CHR(0) is a NUL CHAR that converts to a one-byte STRING. - - STR_TO_NUM always returns REAL and shares parseNumber (strtod, full consumption, overflow rejected, only `0-9 . e E + -` after leading whitespace, so no nan/inf/hex) with IS_NUM and INPUT REAL (`__cps_parse_real` in InputGen.cc); change them together. - - NUM_TO_STR keeps the full signed i64 range for INTEGER; REAL uses the shortest + - STR_TO_NUM defaults to REAL and shares parseNumber (strtod, full consumption, overflow rejected, only `0-9 . e E + -` after leading whitespace, so no nan/inf/hex) with IS_NUM and INPUT REAL (`__cps_parse_real` in InputGen.cc); change them together. Its INTEGER overload applies INT to the parsed REAL, inheriting REAL rounding and truncating toward zero with a range check. + - NUM_TO_STR defaults to STRING; its CHAR overload uses the same text and requires length 1. It keeps the full signed i64 range for INTEGER; REAL uses the shortest round-trip text (realText in string.cc), byte-identical to OUTPUT's IR helper in OutputGen.cc (`__cps_output_real`); change both together. C_DOUBLE output keeps `%f`. - **`getExprTypeInfo` returns nullptr** for expressions it can't classify (null-check diff --git a/AGENTS/PITFALLS/overload-template-operator.md b/AGENTS/PITFALLS/overload-template-operator.md index f4a52ad..909e5f7 100644 --- a/AGENTS/PITFALLS/overload-template-operator.md +++ b/AGENTS/PITFALLS/overload-template-operator.md @@ -13,7 +13,11 @@ Part of the [pitfalls index](../PITFALLS.md). functions still coerce arguments. A known expected result type (assignment, BYVAL argument, RETURN, condition, subscript, CASE comparison) must match the overload's return type exactly; `(T) x` only prefers T and otherwise converts. Without a - context, return-only-distinct candidates are ambiguous. + context, return-only-distinct candidates need one DEFAULT return or remain ambiguous. + DEFAULT never resolves competing parameter signatures. +- Each name and canonical parameter signature permits only one DEFAULT return, + including across invisible units; different parameter signatures may each have + their own. Only non-VOID OVERLOAD functions accept RETURNS DEFAULT. - Call visibility filters the set, but duplicate signatures (parameters and return type) conflict across all inputs. MAIN and builtins cannot be overloaded. - NEW supports overloads; DECLARE, fields and arrays needing default construction @@ -33,7 +37,8 @@ Part of the [pitfalls index](../PITFALLS.md). - Packs are final non-array parameters and expand only in call/constructor argument lists; pack fields are rejected, including in variadic classes. - Unsupported: non-type parameters, SIZEOF..., member/operator templates, - specialization, bare injected class name, pointer-alias templates. Pointer-linked + specialization, bare injected class name, pointer-alias templates, DEFAULT + returns (including methods in class templates). Pointer-linked generic containers remain unsupported; use fixed fields or other supported value layouts. - Class instances follow ordinary constructor rules, so a parameterized NEW alone does @@ -53,7 +58,8 @@ Part of the [pitfalls index](../PITFALLS.md). - Exact matching considers visible globals and left-class members together, and the result type joins the match when the context supplies one; ties are errors, including private/public ties. Without a context, return-only-distinct candidates - are ambiguous; casts only prefer their target type. + need a unique DEFAULT return or remain ambiguous; defaults do not resolve + global/member ties, and casts only prefer their target type. - Comparison and logic result types are declared, not assumed BOOLEAN; a strict BOOLEAN context requires an overload returning BOOLEAN. CASE comparisons must return BOOLEAN. AND/OR overloads evaluate both operands. |
