Skip to content

[Needs Verification] §11.3.1 — nil comparison on unconstrained generic type parameter #51

Description

@NickHodges

Section: §11.3.1

Current text:

Comparison with nil (only if T might be a reference type — ambiguous without constraints)

...listed as permitted without constraints.

Problem:
This may be internally contradictory — it's listed as "permitted" while also being called "ambiguous". The compiler may actually disallow = nil/<> nil on an unconstrained type parameter (compile error) unless a class or interface constraint is present.

Why this needs compiler verification:
Compile a generic method with an unconstrained T that compares a T parameter to nil, and see whether it's accepted or rejected without a class/interface constraint.

Suggested fix (pending verification):
If disallowed: remove nil-comparison from the unconstrained-permitted list and state it requires a class/interface constraint.

Activity

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

    documentationImprovements or additions to documentationneeds-compiler-verificationClaim needs verification against the real Delphi compiler before fixing

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions