lean4-htt/tests/pkg
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
..
builtin_attr refactor: update built-in tactic error messages (#9633) 2025-07-31 14:16:57 +00:00
debug feat: debug_assert! (#7256) 2025-03-03 16:34:44 +00:00
def_clash fix: symbol clashes between packages (#11082) 2025-11-19 02:24:44 +00:00
deriving chore: update tests to account for .lake 2023-11-13 20:31:24 -05:00
frontend chore: re-enable tests (#10923) 2025-10-23 08:38:57 +00:00
initialize fix: missing unboxing in interpreter when loading initialized value (#4512) 2024-06-20 10:06:24 +00:00
linter_set feat: implement "linter sets" that can be turned on as a group (#8106) 2025-05-14 23:30:42 +00:00
misc fix: local syntax should create private definitions 2025-08-19 14:49:12 -07:00
mod_clash test: module clash across packages (#11246) 2025-11-19 02:23:34 +00:00
module chore: make compilation type mismatch error message from non-exposed defs a lot less mysterious (#11177) 2025-11-14 10:50:43 +00:00
path with spaces fix: calling programs with spaces on Windows (#4515) 2024-07-26 17:35:05 +00:00
prv chore: error messages consistency (#10143) 2025-08-26 17:55:43 +00:00
rebuild refactor: lake: mv tests/examples to top-level tests dir (#10688) 2025-10-06 21:47:57 +00:00
setup feat: server support for new module setup (#8699) 2025-06-23 18:00:14 +00:00
signal feat: add signal handling support using libuv (#9258) 2025-09-15 13:09:50 +00:00
structure_docstrings feat: link docstrings for diamond inheritance (#11122) 2025-11-10 01:05:01 +00:00
test_extern test: disable flaky test 2025-04-29 17:34:10 +02:00
user_attr chore: upstream Nat material from mathlib (#7971) 2025-04-16 06:55:32 +00:00
user_attr_app chore: re-enable tests (#10923) 2025-10-23 08:38:57 +00:00
user_ext chore: disable nondeterministic test 2025-04-24 11:30:26 +02:00
user_opt feat: accept user-defined options on the cmdline (#4741) 2024-08-02 12:24:56 +00:00
user_plugin fix: symbol clashes between packages (#11082) 2025-11-19 02:24:44 +00:00
ver_clash test: version clash w/ diamond deps (#11155) 2025-11-13 05:40:56 +00:00
.gitignore test: module clash across packages (#11246) 2025-11-19 02:23:34 +00:00