lean4-htt/doc
Mac Malone 5bb9839887
fix: symbol clashes between packages (#11082)
This PR prevents symbol clashes between (non-`@[export]`) definitions
from different Lean packages.

Previously, if two modules define a function with the same name and were
transitively imported (even privately) by some downstream module,
linking would fail due to a symbol clash. Similarly, if a user defined a
symbol with the same name as one in the `Lean` library, Lean would use
the core symbol even if one did not import `Lean`.

This is solved by changing Lean's name mangling algorithm to include an
optional package identifier. This identifier is provided by Lake via
`--setup` when building a module. This information is weaved through the
elaborator, interpreter, and compiler via a persistent environment
extension that associates modules with their package identifier.

With a package identifier, standard symbols have the form
`lp_<pkg-id>_<mangled-def>`. Without one, the old scheme is used (i.e.,
`l_<mangled-def>`). Module initializers are also prefixed with package
identifier (if any). For example, the initializer for a module `Foo` in
a package `test` is now `initialize_test_Foo` (instead of
`initialize_Foo`). Lake's default for native library names has also been
adjusted accordingly, so that libraries can still, by default, be used
as plugins. Thus, the default library name of the `lean_lib Foo` in
`package test` will now be `libtest_Foo`.

When using Lake to build the Lean core (i.e., `bootstrap = true`), no
package identifier will be used. Thus, definitions in user packages can
never have symbol clashes with core.

Closes #222.
2025-11-19 02:24:44 +00:00
..
dev fix: symbol clashes between packages (#11082) 2025-11-19 02:24:44 +00:00
examples feat: String.toList_map (#11021) 2025-11-01 13:54:39 +00:00
images doc: update quickstart guide for new display name (#5193) 2024-08-28 13:29:16 +00:00
latex doc: upstream the Lean4 pygments lexer (#3125) 2024-05-20 11:40:24 +00:00
make doc: fix broken "quickstart" and "supported editors" link (#8785) 2025-09-02 12:45:04 +00:00
std chore: Grove: bump version (#9419) 2025-07-17 15:02:17 +00:00
.gitignore
BoolExpr.lean chore: Std -> Batteries renaming (#4108) 2024-05-08 05:04:25 +00:00
metaprogramming-arith.lean refactor: remove some unnecessary antiquotation kind annotations 2022-07-23 17:09:32 +02:00
perf.md doc: add basic perf documentation 2021-09-06 07:12:36 -07:00
README.md chore: remove old documentation site (#7974) 2025-05-14 14:31:33 +00:00
style.md doc: add documentation style guide (#8199) 2025-05-02 13:05:18 +00:00
syntax_example.lean doc: fix example style 2022-04-22 16:26:16 +02:00

Developer Documentation and Examples

This directory contains documentation that describes how to work on Lean itself, as well as examples that are included in documentation that's hosted on the Lean website. The make directory contains information on building Lean, and the dev directory describes how to work on Lean.

The documentation section has links to documentation that describes how to use Lean itself.