Skip to content

Concrete classes and their subclasses

Rudi Cilibrasi edited this page Nov 13, 2026 · 1 revision

<concrete> classes and their subclasses: the Book's prose versus its tests

A note on one place where the pinned Book of Verse (revision beaa719b) disagrees with its own tests. Written 2026-11-13 against openverse main 756569a. Status: waiting for the owner's decision.

The question

If a class base is <concrete>, must a subclass that is not marked <concrete> also give every field a default?

What the prose says

Chapter 10, "Concrete" (docs/10_*.md, lines 2110–2111):

A concrete class C can be constructed with C{}. A concrete class may have subclasses that are not concrete.

Read plainly, a subclass may add a field with no default.

What the tests say

They consistently refuse exactly that, with error 3519:

base := class<concrete>:
    valueBase:int = 42
child := class(base):
    valueChild:int          # 3519 - needs an initializer because base is concrete
  • Seven cases: Tests/Bugs/SOL-3366-MakeClassesConcreteByDefault.versetest lines 8, 15, 24; Tests/Attributes/concrete.versetest lines 38, 76; Tests/Bugs/SOL-7781-ConcreteClassDoesntEnforceDefaultValuesForInterfaceFields.versetest lines 28, 54.
  • The requirement carries down the chain: a grandchild's field needs a default "because basebase is concrete".
  • No test accepts a subclass of a concrete class with an undefaulted field. The accepted subclasses either add no fields or default every one.

How the two can be reconciled

The prose sentence may only mean that a subclass need not carry the specifier; the tests show that the requirement is inherited regardless. On that reading there is no contradiction, only a loosely worded sentence. The bug file's title, "make classes concrete by default", suggests the inherited behaviour was a deliberate change.

A likely reason for the tests' rule

This is an inference, not something the Book states. Chapter 11's concrete_subtype(t) exists so that code holding "some subclass of entity" can safely write EntityType{}. That is only safe if every subclass of a concrete class can itself be constructed with an empty archetype.

One wrinkle inside the tests

Tests/Attributes/concrete.versetest lines 110–114 accept a subclass that re-declares an inherited field with <override> and no value, under the test's own comment "is this actually valid?". The prose says an <override> without a value does not satisfy the requirement for a <concrete> class itself. So that one case is uncertain even to its authors.

Where openverse stands

openverse follows the plain reading of the prose: a <concrete> class's own fields need defaults (since #595), but an unmarked subclass's do not. The seven cases above are counted in the Book test survey (docs/research/book-test-conformance.md) as "accepts what the tests refuse".

Recommendation

Follow the tests: the default requirement is inherited by every class below a <concrete> one.

  • It is the behaviour the tests pin seven times.
  • It matches concrete_subtype.
  • The prose can be read to agree.
  • It is a small change: one more rule next to the existing concrete check.

Keep accepting the <override>-without-value case, as the tests do, and note it as uncertain.

Decision

Open. The owner's standing rule is to follow the Book; this is held back only because the Book disagrees with itself here.