Skip to content

Let a root with entries rebind prelude constructors - #223

Merged
jbwinters merged 2 commits into
mainfrom
task/304-type3
Nov 9, 2026
Merged

jbwinters merged 2 commits into
mainfrom
task/304-type3

Conversation

@jbwinters

Copy link
Copy Markdown
Collaborator

Abstract-types hardening, seventh part: let a root project with entries rebind prelude constructor names.

A root project's library may declare its own type with a prelude type's name and constructors (for example opaque type Bool = | False | True); the library check already accepted this, and the abstract-types decision record says roots may rebind prelude names. But once the project had an entry, the entry check re-counted the library's True and the prelude's True as two visible owners and refused the whole project with E1731, even when the entry declared nothing.

Change:

  • src/project_frontend.ml: the entry check no longer re-reports clashes among the composed library, its direct dependencies and the prelude. The library check has already judged those, and the root is composed only after it passes. An entry's own constructors are still judged against everything visible, including the library's, so an entry declaring type Flag = | True beside a rebound Bool is still E1731.
  • E1731 now names the root's own constructors as of this project instead of of the library.

Tests:

  • test/cli/opaque-matrix.t: a root rebinding Bool and Result runs against its dependency on the interpreter and natively with identical output. The dependency's code and the builtins it calls return prelude values beside the root's <opaque bool> and <opaque result>. An entry's colliding constructor is refused. A root with no dependency runs on the interpreter. Relational-comparison prose now says exactly what the Int control shows.
  • test/cli/project-local.t: updated wording.

Docs and prose: docs/designs/project-structure.md states the same-type-name exception and how entries are judged; src/project_frontend.mli lists entry constructors under E1731; a host-session test comment, the g54 gauntlet header and its MAPPING row are corrected; docs/release/0.3/SLICES.md gains the seventh-part entry. The source inventory is unchanged at 1246 tests, 85 cram files, 57 doctest examples.

Verification: full local gate (build, dune runtest, formatting) exit 0 on the head.

The entry check re-reported clashes between the composed library's own
constructors and the prelude's, which the library check had already
accepted, so a root project that runs an entry could not declare its own
opaque Bool or Result. The entry check now judges only the entry's own
constructors. E1731 names the root's constructors as 'of this project'.
Small test prose corrections.
Review follow-ups: the design names the same-type-name exception to the
constructor collision rule, the interface lists entry constructors under
E1731, and the test and slice prose no longer credit builtins with values the
dependency's own code builds or claim a native run without a dependency.
@jbwinters
jbwinters enabled auto-merge (squash) November 9, 2026 03:24
@jbwinters
jbwinters merged commit e5907c7 into main Nov 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant