Repository navigation
Conversation
…ses) uses export (unleashed mode): a unit passes units of its interface uses clause on to the units that use it, so one name brings a whole set (C# global using, Rust pub use, TS export *). unit Lumi; interface uses export UI.Forms, UI.StdCtrls, Data.Window; - "export" right after "uses" covers the clause; before a later unit, that unit only. In the implementation uses clause it is error 03448. - A user sees the passed-on units as if they stood right before the re-exporting unit: its own names win, later units of the user win over both, and every passed-on unit stays reachable by its qualified name. Transitive. Naming a passed-on unit again is no duplicate. - The user records the passed-on units as used units (their crc goes into its ppu), so a change of their interface recompiles it. - No "unit not used" hint for a unit used only for what it passes on, nor for the passed-on units inside the re-exporting unit. - PPU: interface entry ibreexportunits (counted in the interface crc); PPU long version 49. --project-uses=A,B: every unit and program of the run uses A and B, as if they stood first in its uses clause (-Fa covers programs only). A unit that is one of them does not get itself; the units such a unit is built from do not get it either (they are loaded while its interface is not compiled yet; giving it to them would be a circular reference with -B). Naming them again is no duplicate. Wildcards (uses UI.*) were considered and left out: the hiding order would not be in the source, and adding a unit to a folder would change what an unchanged program means. qualification/compiler-uses-export: re-export, per-unit export, the implementation error, no unused hint, recompilation, project uses with and without -B. Documentation: unleashed/docs/uses-export.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two additions to unit handling, for applications built on a set of library units:
uses export(unleashed mode): a unit passes units of its interface uses clause on to the units that use it, so one name brings a whole set (C#global using, Rustpub use, TypeScriptexport *).--project-uses=A,B: every unit and program of the run uses A and B, as if they stood first in its uses clause.-Faonly covers programs.Semantics
exportright afterusescovers the clause; before a later unit, that unit only. In the implementation uses clause it is an error (03448).--project-uses: a unit that is one of the listed units does not get itself; the units such a unit is built from do not get it either (they are loaded while its interface is not compiled yet; with-Bgiving it to them would be a circular reference). Naming the units again is no duplicate.uses UI.*) were considered and left out: the hiding order would not be in the source, and adding a unit to a folder would change what an unchanged program means.Implementation
pmodules.pas: parsing (parseusesclause),connect_loaded_unitspushes the passed-on units before the re-exporting one and registers them as used units of the user (with a unit symbol for qualified names);addprojectusesfor units and programs.fmodule.pas:tused_unit.reexport/via_reexport/via_project;allunitsusedhint rules.fppu.pas,entfile.pas,ppu.pas: interface entryibreexportunits(counted in the interface crc), PPU long version 49.options.pas,globals.pas:--project-uses(the options are read more than once, units are added once).msg/errore.msg:parser_e_reexport_uses_in_implementation(03448).unleashed/docs/uses-export.md, index entry inunleashed/docs/README.md.Test plan
qualification/compiler-uses-export/run_gate.py: 8 cases (re-export and name order, per-unit export, the implementation error, no unused-unit hint, recompilation of a user when a passed-on unit changes, project uses with and without-B), on a toolchain built from this branch withbuild.ps1 compiler.uses Lumi/lumi.json "uses"), its full test suite passing.🤖 Generated with Claude Code