Skip to content

Commit 8d74aa2

Browse files
authored
Merge branch 'master' into LilithHafner-patch-1
2 parents c1cb0b8 + 34070fa commit 8d74aa2

File tree

10 files changed

+59
-31
lines changed

10 files changed

+59
-31
lines changed

Compiler/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Compiler"
22
uuid = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1"
3-
version = "0.0.0"
3+
version = "0.1.0"
44

55
[compat]
66
julia = "1.10"

Compiler/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ your `Project.toml` as follows:
1616
Compiler = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1"
1717

1818
[compat]
19-
Compiler = "0"
19+
Compiler = "0.1"
2020
```
2121

22-
With the setup above, [the special placeholder version (v0.0.0)](https://github.com/JuliaLang/BaseCompiler.jl)
22+
With the setup above, [the special placeholder version (v0.1.0)](https://github.com/JuliaLang/BaseCompiler.jl)
2323
will be installed by default.[^1]
2424

25-
[^1]: Currently, only version v0.0.0 is registered in the [General](https://github.com/JuliaRegistries/General) registry.
25+
[^1]: Currently, only version v0.1.0 is registered in the [General](https://github.com/JuliaRegistries/General) registry.
2626

2727
If needed, you can switch to a custom implementation of the `Compiler` module by running
2828
```julia-repl

base/deepcopy.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ where `T` is the type to be specialized for, and `dict` keeps track of objects c
2323
so far within the recursion. Within the definition, `deepcopy_internal` should be used
2424
in place of `deepcopy`, and the `dict` variable should be
2525
updated as appropriate before returning.
26+
27+
!!! warning
28+
It is better to avoid this function in favor of custom `copy` methods or use-case-specific
29+
copying functions. `deepcopy` is slow and can easily copy too many objects, or generate an
30+
object that violates invariants, since it does not respect abstraction boundaries.
2631
"""
2732
function deepcopy(@nospecialize x)
2833
isbitstype(typeof(x)) && return x

base/loading.jl

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2715,7 +2715,7 @@ end
27152715

27162716
# load a serialized file directly from append_bundled_depot_path for uuidkey without stalechecks
27172717
"""
2718-
require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}=nothing)
2718+
require_stdlib(package_uuidkey::PkgId, [ext::String, from::Module])
27192719
27202720
!!! warning "May load duplicate copies of stdlib packages."
27212721
@@ -2754,7 +2754,8 @@ end
27542754
[1] https://github.com/JuliaLang/Pkg.jl/issues/4017#issuecomment-2377589989
27552755
[2] https://github.com/JuliaLang/StyledStrings.jl/issues/91#issuecomment-2379602914
27562756
"""
2757-
function require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}=nothing)
2757+
require_stdlib(package_uuidkey::PkgId) = require_stdlib(package_uuidkey, nothing, Base)
2758+
function require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}, from::Module)
27582759
if generating_output(#=incremental=#true)
27592760
# Otherwise this would lead to awkward dependency issues by loading a package that isn't in the Project/Manifest
27602761
error("This interactive function requires a stdlib to be loaded, and package code should instead use it directly from that stdlib.")
@@ -2766,15 +2767,29 @@ function require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}=noth
27662767
newm = start_loading(this_uuidkey, UInt128(0), true)
27672768
newm === nothing || return newm
27682769
try
2769-
# first since this is a stdlib, try to look there directly first
2770-
if ext === nothing
2771-
sourcepath = normpath(env, this_uuidkey.name, "src", this_uuidkey.name * ".jl")
2772-
else
2773-
sourcepath = find_ext_path(normpath(joinpath(env, package_uuidkey.name)), ext)
2774-
end
27752770
depot_path = append_bundled_depot_path!(empty(DEPOT_PATH))
2776-
set_pkgorigin_version_path(this_uuidkey, sourcepath)
2777-
newm = _require_search_from_serialized(this_uuidkey, sourcepath, UInt128(0), false; DEPOT_PATH=depot_path)
2771+
from_stdlib = true # set to false if `from` is a normal package so we do not want the internal loader for the extension either
2772+
if ext isa String
2773+
from_uuid = PkgId(from)
2774+
from_m = get(loaded_modules, from_uuid, nothing)
2775+
if from_m === from
2776+
# if from_uuid is either nothing or points to something else, assume we should use require_stdlib
2777+
# otherwise check cachepath for from to see if it looks like it is from depot_path, since try_build_ids
2778+
cachepath = get(PkgOrigin, pkgorigins, from_uuid).cachepath
2779+
entrypath, entryfile = cache_file_entry(from_uuid)
2780+
from_stdlib = any(x -> startswith(entrypath, x), depot_path)
2781+
end
2782+
end
2783+
if from_stdlib
2784+
# first since this is a stdlib, try to look there directly first
2785+
if ext === nothing
2786+
sourcepath = normpath(env, this_uuidkey.name, "src", this_uuidkey.name * ".jl")
2787+
else
2788+
sourcepath = find_ext_path(normpath(joinpath(env, package_uuidkey.name)), ext)
2789+
end
2790+
set_pkgorigin_version_path(this_uuidkey, sourcepath)
2791+
newm = _require_search_from_serialized(this_uuidkey, sourcepath, UInt128(0), false; DEPOT_PATH=depot_path)
2792+
end
27782793
finally
27792794
end_loading(this_uuidkey, newm)
27802795
end
@@ -2784,10 +2799,12 @@ function require_stdlib(package_uuidkey::PkgId, ext::Union{Nothing, String}=noth
27842799
run_package_callbacks(this_uuidkey)
27852800
else
27862801
# if the user deleted their bundled depot, next try to load it completely normally
2802+
# if it is an extension, we first need to indicate where to find its parant via EXT_PRIMED
2803+
ext isa String && (EXT_PRIMED[this_uuidkey] = PkgId[package_uuidkey])
27872804
newm = _require_prelocked(this_uuidkey)
27882805
end
27892806
return newm
2790-
end
2807+
end # release lock
27912808
end
27922809

27932810
# relative-path load

base/reflection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,11 +1035,11 @@ function hasmethod(f, t, kwnames::Tuple{Vararg{Symbol}}; world::UInt=get_world_c
10351035
match = ccall(:jl_gf_invoke_lookup, Any, (Any, Any, UInt), tt, nothing, world)
10361036
match === nothing && return false
10371037
kws = ccall(:jl_uncompress_argnames, Array{Symbol,1}, (Any,), (match::Method).slot_syms)
1038+
kws = kws[((match::Method).nargs + 1):end] # remove positional arguments
10381039
isempty(kws) && return true # some kwfuncs simply forward everything directly
10391040
for kw in kws
10401041
endswith(String(kw), "...") && return true
10411042
end
1042-
kwnames = collect(kwnames)
10431043
return issubset(kwnames, kws)
10441044
end
10451045

doc/Manifest.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ version = "0.9.4"
4444

4545
[[deps.Documenter]]
4646
deps = ["ANSIColoredPrinters", "AbstractTrees", "Base64", "CodecZlib", "Dates", "DocStringExtensions", "Downloads", "Git", "IOCapture", "InteractiveUtils", "JSON", "Logging", "Markdown", "MarkdownAST", "Pkg", "PrecompileTools", "REPL", "RegistryInstances", "SHA", "TOML", "Test", "Unicode"]
47-
git-tree-sha1 = "7745f07eaf6454c15caa21c5ecaebef3afad32eb"
47+
git-tree-sha1 = "6f8730fd1bdf974009ef296bd81afb2728854fc0"
4848
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
49-
version = "1.11.1"
49+
version = "1.11.3"
5050

5151
[[deps.Downloads]]
5252
deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]

doc/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ const devurl = "v$(VERSION.major).$(VERSION.minor)-dev"
450450

451451
# Hack to make rc docs visible in the version selector
452452
struct Versions versions end
453+
Documenter.determine_deploy_subfolder(deploy_decision, ::Versions) = deploy_decision.subfolder
453454
function Documenter.Writers.HTMLWriter.expand_versions(dir::String, v::Versions)
454455
# Find all available docs
455456
available_folders = readdir(dir)

stdlib/REPL/src/Pkg_beforeload.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
# This file is a part of Julia. License is MIT: https://julialang.org/license
2+
13
## Pkg stuff needed before Pkg has loaded
24

35
const Pkg_pkgid = Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg")
4-
load_pkg() = Base.require_stdlib(Pkg_pkgid, "REPLExt")
6+
load_pkg() = Base.require_stdlib(Pkg_pkgid, "REPLExt", REPL)
57

68
## Below here copied/tweaked from Pkg Types.jl so that the dummy Pkg prompt
79
# can populate the env correctly before Pkg loads

stdlib/REPL/src/REPL.jl

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,8 @@ function repl_backend_loop(backend::REPLBackend, get_module::Function)
452452
try
453453
ret = f()
454454
put!(backend.response_channel, Pair{Any, Bool}(ret, false))
455-
catch err
456-
put!(backend.response_channel, Pair{Any, Bool}(err, true))
455+
catch
456+
put!(backend.response_channel, Pair{Any, Bool}(current_exceptions(), true))
457457
end
458458
else
459459
ast = ast_or_func
@@ -594,11 +594,11 @@ function print_response(errio::IO, response, backend::Union{REPLBackendRef,Nothi
594594
if val !== nothing && show_value
595595
val2, iserr = if specialdisplay === nothing
596596
# display calls may require being run on the main thread
597-
eval_with_backend(backend) do
597+
call_on_backend(backend) do
598598
Base.invokelatest(display, val)
599599
end
600600
else
601-
eval_with_backend(backend) do
601+
call_on_backend(backend) do
602602
Base.invokelatest(display, specialdisplay, val)
603603
end
604604
end
@@ -715,7 +715,7 @@ function run_frontend(repl::BasicREPL, backend::REPLBackendRef)
715715
(isa(ast,Expr) && ast.head === :incomplete) || break
716716
end
717717
if !isempty(line)
718-
response = eval_with_backend(ast, backend)
718+
response = eval_on_backend(ast, backend)
719719
print_response(repl, response, !ends_with_semicolon(line), false)
720720
end
721721
write(repl.terminal, '\n')
@@ -1166,21 +1166,23 @@ find_hist_file() = get(ENV, "JULIA_HISTORY",
11661166
backend(r::AbstractREPL) = hasproperty(r, :backendref) ? r.backendref : nothing
11671167

11681168

1169-
function eval_with_backend(ast::Expr, backend::REPLBackendRef)
1169+
function eval_on_backend(ast, backend::REPLBackendRef)
11701170
put!(backend.repl_channel, (ast, 1)) # (f, show_value)
11711171
return take!(backend.response_channel) # (val, iserr)
11721172
end
1173-
function eval_with_backend(f, backend::REPLBackendRef)
1173+
function call_on_backend(f, backend::REPLBackendRef)
1174+
applicable(f) || error("internal error: f is not callable")
11741175
put!(backend.repl_channel, (f, 2)) # (f, show_value) 2 indicates function (rather than ast)
11751176
return take!(backend.response_channel) # (val, iserr)
11761177
end
11771178
# if no backend just eval (used by tests)
1178-
function eval_with_backend(f, backend::Nothing)
1179+
eval_on_backend(ast, backend::Nothing) = error("no backend for eval ast")
1180+
function call_on_backend(f, backend::Nothing)
11791181
try
11801182
ret = f()
11811183
return (ret, false) # (val, iserr)
1182-
catch err
1183-
return (err, true)
1184+
catch
1185+
return (current_exceptions(), true)
11841186
end
11851187
end
11861188

@@ -1196,7 +1198,7 @@ function respond(f, repl, main; pass_empty::Bool = false, suppress_on_semicolon:
11961198
local response
11971199
try
11981200
ast = Base.invokelatest(f, line)
1199-
response = eval_with_backend(ast, backend(repl))
1201+
response = eval_on_backend(ast, backend(repl))
12001202
catch
12011203
response = Pair{Any, Bool}(current_exceptions(), true)
12021204
end
@@ -1803,7 +1805,7 @@ function run_frontend(repl::StreamREPL, backend::REPLBackendRef)
18031805
if have_color
18041806
print(repl.stream, Base.color_normal)
18051807
end
1806-
response = eval_with_backend(ast, backend)
1808+
response = eval_on_backend(ast, backend)
18071809
print_response(repl, response, !ends_with_semicolon(line), have_color)
18081810
end
18091811
end

test/reflection.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,7 @@ f(x::Int; y=3) = x + y
936936
@test hasmethod(f, Tuple{Int})
937937
@test hasmethod(f, Tuple{Int}, ())
938938
@test hasmethod(f, Tuple{Int}, (:y,))
939+
@test !hasmethod(f, Tuple{Int}, (:x,))
939940
@test !hasmethod(f, Tuple{Int}, (:jeff,))
940941
@test !hasmethod(f, Tuple{Int}, (:y,), world=typemin(UInt))
941942
g(; b, c, a) = a + b + c

0 commit comments

Comments
 (0)