This either a PSA or a bug report; I'm not sure which tbh.
Suppose you have the following file structure:
Pkg/
MyCode.lpk
Units/
MyCode.pas
This will lead to confusing "Identifier not found" error messages. Worse still, the IDE will be able to find and even point you to those identifiers declarations, but the compiler will still complain they do not exists.
This behavior arises because, "under" the hood, an empty unit "Pkg/MyCode.pas" (note the path and extension) is created to pull in all units from the MyCode package. Since both "Pkg/MyCode.pas" and "Pkg/Units/MyCode.pas" have the same unit identifier and are compiled into the same output directory (under Pkg/lib/), the compiler picks up the empty unit (which is compiled last).
I do realize this is an unfortunate set of coincidences, but it surely made me waste a good hour figuring it out. Would it be possible to at least add an warning should this situation occur? Or, ideally, remove the need for the empty unit in the first place?