Three compiler additions, exercised end-to-end by testpunit2.pas: * Default parameter values — single-name, non-var, non-open-array params may carry '= literal-or-named-constant'. Overload resolution accepts any arity in [MinArity, ParamCount]; the resolver tie-breaks toward the candidate that needs fewer defaulted slots. AnalyseProcCall and AnalyseFuncCallExpr clone the default expression into the call's Args list. Defaults declared on a unit-interface forward decl are ownership-transferred to the matching impl param at reconciliation. * Metaclass references — a bare class type identifier in a value position (e.g. 'EError' as an argument or in 'Pointer(EError)') is now retyped to Pointer with codegen emitting '$typeinfo_<Name>' as an immediate. Matches the value held by vtable[0], so 'A.ClassType = EError' is true exactly when A is an instance of that exact class. * Numeric widening at call sites — the existing CoerceArg helper now covers Integer→Double (swtof/sltof), Single→Double (exts) and Integer→Single, in addition to the pre-existing w→l. Inherited-, constructor-, method-, and function-call sites all route through it. punit.pas gains DefaultDoubleDelta, two Double AssertEquals overloads, and '= ''' defaults on the four-arity AddTest declarations. Docs: grammar.ebnf extends ParamGroup with the optional default; a new DefaultValue rule lists the permitted forms. language-rationale.adoc adds 'Default Parameter Values' and 'Metaclass References' sections recording the decision, alternatives rejected, and the overload tie-break formula. All 1194 existing compiler tests pass; testpunit2 compiles, assembles, links and runs (31 tests; the expected pass/fail/inactive pattern). |
||
|---|---|---|
| .. | ||
| design.adoc | ||
| future-improvements.adoc | ||
| grammar.ebnf | ||
| language-rationale.adoc | ||