alpha-2027 · draft-alpha-2027 · tests/language/draft/bare-nameView source

Feature contract: a family or constructor named alone#

1. Lexical and grammar rules, including precedence and termination#

No new syntax: the term is an identifier. In alpha-2027 an unqualified name X that nothing else binds means (family X) when X is a family with no parameters or indices, and (constructor F X) when X is a constructor with no fields of a family F with no parameters. A family or constructor that needs arguments keeps its form, and a name is never applied this way: (C a) is an application of a variable C, not a constructor application.

2. Scope and binding rules, including generated names#

This is the last rule of name resolution (SPECIFICATION §3.2): a local binder, a definition of the module and an imported definition all answer first, so a name reaches it only where it was unbound before. Families and constructors are visible as their long spellings are, through a direct import or the module's own declarations; inside a family's declaration its own name is not yet visible. A name that two visible declarations share, such as a family and its constructor, or constructors of two families, is ambiguous and is refused with both spellings listed. No names are generated.

3. Type and quantity requirements#

Those of the long spelling. Quantities are unaffected: the name refers to no variable.

4. Effects, totality, and evaluation-order rules#

Pure; a family is a type and a nullary constructor is a value.

5. Elaboration into existing core or a specifically versioned new core extension#

Elaborate.insertBareNullaryNames adds each name to the module's definition environment after the real definitions, holding the term the long spelling elaborates to, and a family declaration sees the same names after its closed bindings. The core is identical to the long spelling's. The kernel is unchanged.

6. Representation and target support, where relevant#

Unchanged.

7. Error codes and primary/secondary origins#

ALPHA-ELAB-SCOPE at the name: ambiguous (the message lists both spellings), a constructor with fields (the message writes out the form it needs), or a family with parameters or indices.

8. Formatting and migration rules#

The formatter prints the name. The registered migration bare-nullary-name rewrites (family X) to X and (constructor F C) to C, and alpha migrate proves each rewritten module keeps its core. It leaves a form spelled out when a comment is inside it, when it is the head of a nest, when it qualifies a name, when a family names itself inside its own declaration, and when anything in the closure binds the name or two declarations share it (Migrate.bareNameConflicts).

9. Positive, negative, execution, and edge-case tests#

tests/language/draft/bare-name/: both forms with refl against their long spellings, a match-with over bare constructors, a native run (exit 8), a binder and a definition hiding a family's constructors, and the refusals in the front matter. debug/lang-contract-check.py checks the edition both ways with tests/language/BareNameUnderAlpha2026.alpha. debug/migrate-check.py covers each case the rewrite leaves alone.

10. Compatibility with the old edition, serialized forms, and cache keys#

Under alpha-2026 a name that needs this rule stays ALPHA-ELAB-SCOPE, as it always was (Module.moduleForEdition): a lexeme scan cannot tell a bare name from a variable, so the edition is applied where names are resolved rather than by the gate that reports ALPHA-EDITION-UNSUPPORTED-FORM. Long spellings stay valid in both editions. No core, interface or artifact schema changes.

Known discrepancies and limits#

  • A constructor that takes fields keeps its (constructor F C ...) form.
  • alpha lint, symbol references and LSP navigation see a bare name as a variable with no definition of its own.
  • The self-hosted front end (packages/compiler) does not resolve bare names.