feat(checker): the prelude ranks below the file #346
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/50-prelude-ranks-last"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #50
The prelude now ranks below everything a file wrote or imported, for names and for members, as decided in #50.
What changes
asname and an imported case already shadowed a prelude name); now specified and tested. The scope records which names came from the prelude (ModuleScope.preludeNames).usenames, a trait that is a name of the file without the prelude. Prelude-only: a member the prelude re-exports, a trait only the prelude names. The first class answers before the second whatever the specificity; inside a class the old rules stay (specificity, then the ambiguity at the use).scope.trb: the prelude's member entries carrythroughPrelude;Program.namesMemberItself.implementation.trb:isExtensionWrittenHere,isTraitWrittenHereand the cachedwrittenSymbolsOfderive the class.member.trb:searchMemberruns file extensions, file traits, prelude extensions, prelude traits in that order;extensionMembertakes the class;traitCandidatesOfranks trait candidates.A design point for review
A trait of the file shuts out the prelude's other traits with a member of that name, but not other implementations of the same trait. Otherwise
From<JsonValue>(implemented by a package the file reaches only through the prelude) would drop out of theFrom<...>overload set whenever the receiver's own package implementsFromas well, which would be a behaviour change no one asked for. The overload set is decided by the arguments, not a collision.One more behaviour change, as the decision allows: a file-class trait member now beats a prelude-only extension (before, any visible extension beat any trait member). In
stdthe prelude re-exports onlyIterate/Cut/List.parallelandInt64.seconds/milliseconds, and no trait has a member of those names on those receivers.visibleModulesOf/isVisibleModuleinimplementation.trb, which the refine named as the place for the provenance, have no callers today; the class is derived from the member imports and the scope's names instead.Tests
implementations.test.trb, new group "The prelude ranks below the file" (a project whose prelude isacme/basere-exporting fromacme/loud): the prelude's member reaches the file; (a) the file's import ofString.shoutwins; (b) the file'sextend<Item> Iterate<Item>member wins over a preludeListmember, with and without the prelude member; (c) two prelude-only members and two file members are still the ambiguity; (e) a trait the file names wins over one only the prelude names.check.test.trb, "Preludes": (d) a name the prelude gains does not change a declaration, anasimport, an imported case or a bare case in a pattern.Docs
CONCEPT "Imports" ("The prelude and collisions"), the reference page
language/modules-and-packages/the-prelude.md(rule 6, mirrored intoskills/), TYPECHECKER 3.1 (step order, the member rule, the stale implicit-parameter sentence removed), RELEASE.md section 2 (resolved 2026-10-12) and section 3'sstdrow, ROADMAP (row and milestone 8 text).Locally only
torb format --check,torb checkofcompiler/andtorb docs skill docs skills --check(nightly toolchain); the new tests run in CI.bdc2393c5deddd214029eddd214029e96773f169Approved.
implementations.test.trbandcheck.test.trbcover names and members (file import, file extension, ambiguity within a class, trait ranking). CI green for this head, including tier A, bootstrap, pdisc.searchMemberorder (file extensions, file traits, prelude extensions, prelude traits) matches the PR body and the docs;traitCandidatesOfkeeps the same-trait overload set (From<...>) and the supertrait override dedup;throughPreludeis set only on prelude-derived member entries.Non-blocking:
visibleModulesOf/isVisibleModuleremain uncalled; consider removing them in a follow-up.