Skip to content

[Correction] §14.2.1 — FreeAndNil signature shown as const [ref], contradicts its mutating behavior #39

Description

@NickHodges

Section: §14.2.1 FreeAndNil

Current text:

procedure FreeAndNil(const [ref] Obj: TObject);

Problem:
FreeAndNil must set the caller's variable to nil. A const [ref] parameter (the [ref] modifier just forces pass-by-reference; it doesn't make const writable) cannot be assigned to inside the routine. The declared signature contradicts the described behavior.

Suggested fix:
Use a mutable parameter, e.g. procedure FreeAndNil(var Obj: TObject); — verify the exact current RTL declaration in System.SysUtils.pas rather than asserting const [ref].

Activity

  1. added
    bugSomething isn't working
    documentationImprovements or additions to documentation
    on Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions