From 51d352d997776f49d021f62839a951f897dab170 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Tue, 30 Sep 2025 10:11:42 -0400 Subject: [PATCH 1/2] Make `Base.get_extension` private to prevent user mistakes Added in JuliaLang/julia#58108 without valid justification: something simply being documented in the manual is never any allowable argument for making something public. Being public is confusing users, since all of the other related infrastructure is also declared private (project files, `loaded_modules_array`, `PkgId`, `require`, etc.). Some of those do have legit uses in reflection testing, but we don't currently have a representation for this sort of private-except-reflection in most places (other than `Core.IR`). However is not allowed for packages to call `Base.get_extension`, since it requires accessing private implementation details of the target package to construct the arguments, and can run afoul of various implementation rules (world ages, module identity, precompile file consistency) that can lead to buggy execution. The correct way to use this functionality is with dispatch. Loosely: ```julia module Main function get_extension end end module MainPkgExt # extension module in Main using Other Main.get_extension(args...) = Other.call(args...) end ``` --- base/loading.jl | 4 +++- base/public.jl | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/base/loading.jl b/base/loading.jl index 5da5cc931421f..1420b5bfe5115 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1643,7 +1643,9 @@ end """ get_extension(parent::Module, extension::Symbol) -Return the module for `extension` of `parent` or return `nothing` if the extension is not loaded. +Return the module for `extension` relative to `parent` or return `nothing` if the extension is not loaded. +This function is private, since the arguments to it are private implementation details. +It is provided mainly for testing and reflection purposes. """ get_extension(parent::Module, ext::Symbol) = get_extension(PkgId(parent), ext) function get_extension(parentid::PkgId, ext::Symbol) diff --git a/base/public.jl b/base/public.jl index 9be5e535339a3..5953c684d1963 100644 --- a/base/public.jl +++ b/base/public.jl @@ -54,7 +54,6 @@ public active_project, # Reflection and introspection - get_extension, isambiguous, isexpr, isidentifier, From bafa9cca63afd441a8a76bbb342b2f36f475bbc3 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Tue, 7 Oct 2025 11:50:47 -0400 Subject: [PATCH 2/2] Update public.jl --- base/public.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/base/public.jl b/base/public.jl index 5953c684d1963..9be5e535339a3 100644 --- a/base/public.jl +++ b/base/public.jl @@ -54,6 +54,7 @@ public active_project, # Reflection and introspection + get_extension, isambiguous, isexpr, isidentifier,