Skip to content

Commit 5da7baf

Browse files
authored
Merge branch 'master' into caf/merge-julia-frontend
2 parents df28c66 + 5957579 commit 5da7baf

36 files changed

+3897
-731
lines changed

Compiler/test/inference.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3509,11 +3509,11 @@ end
35093509
struct MixedKeyDict{T<:Tuple} #<: AbstractDict{Any,Any}
35103510
dicts::T
35113511
end
3512-
Base.merge(f::Function, d::MixedKeyDict, others::MixedKeyDict...) = _merge(f, (), d.dicts, (d->d.dicts).(others)...)
3513-
Base.merge(f, d::MixedKeyDict, others::MixedKeyDict...) = _merge(f, (), d.dicts, (d->d.dicts).(others)...)
3512+
Base.mergewith(f::Function, d::MixedKeyDict, others::MixedKeyDict...) = _merge(f, (), d.dicts, (d->d.dicts).(others)...)
3513+
Base.mergewith(f, d::MixedKeyDict, others::MixedKeyDict...) = _merge(f, (), d.dicts, (d->d.dicts).(others)...)
35143514
function _merge(f, res, d, others...)
35153515
ofsametype, remaining = _alloftype(Base.heads(d), ((),), others...)
3516-
return _merge(f, (res..., merge(f, ofsametype...)), Base.tail(d), remaining...)
3516+
return _merge(f, (res..., mergewith(f, ofsametype...)), Base.tail(d), remaining...)
35173517
end
35183518
_merge(f, res, ::Tuple{}, others...) = _merge(f, res, others...)
35193519
_merge(f, res, d) = MixedKeyDict((res..., d...))
@@ -3537,9 +3537,9 @@ _alloftype(ofdesiredtype, accumulated) = ofdesiredtype, Base.front(accumulated)
35373537
let
35383538
d = MixedKeyDict((Dict(1 => 3), Dict(4. => 2)))
35393539
e = MixedKeyDict((Dict(1 => 7), Dict(5. => 9)))
3540-
@test merge(+, d, e).dicts == (Dict(1 => 10), Dict(4.0 => 2, 5.0 => 9))
3540+
@test mergewith(+, d, e).dicts == (Dict(1 => 10), Dict(4.0 => 2, 5.0 => 9))
35413541
f = MixedKeyDict((Dict(2 => 7), Dict(5. => 11)))
3542-
@test merge(+, d, e, f).dicts == (Dict(1 => 10, 2 => 7), Dict(4.0 => 2, 5.0 => 20))
3542+
@test mergewith(+, d, e, f).dicts == (Dict(1 => 10, 2 => 7), Dict(4.0 => 2, 5.0 => 20))
35433543
end
35443544

35453545
# Issue #31974

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ New library features
7878
* `Base.ScopedValues.LazyScopedValue{T}` is introduced for scoped values that compute their default using a
7979
`OncePerProcess{T}` callback, allowing for lazy initialization of the default value. `AbstractScopedValue` is
8080
now the abstract base type for both `ScopedValue` and `LazyScopedValue`. ([#59372])
81+
* New `Base.active_manifest()` function to return the path of the active manifest, like `Base.active_project()`.
82+
Also can return the manifest that would be used for a given project file ([#57937])
8183

8284
Standard library changes
8385
------------------------
@@ -99,6 +101,7 @@ Standard library changes
99101
* The Julia REPL now support bracketed paste on Windows which should significantly speed up pasting large code blocks into the REPL ([#59825])
100102
* The REPL now provides syntax highlighting for input as you type. See the REPL docs for more info about customization.
101103
* The REPL now supports automatic insertion of closing brackets, parentheses, and quotes. See the REPL docs for more info about customization.
104+
* History searching has been rewritten to use a new interactive modal dialogue, using a fzf-like style.
102105
* The display of `AbstractChar`s in the main REPL mode now includes LaTeX input information like what is shown in help mode ([#58181]).
103106
* Display of repeated frames and cycles in stack traces has been improved by bracketing them in the trace and treating them consistently ([#55841]).
104107

@@ -120,4 +123,9 @@ External dependencies
120123
Tooling Improvements
121124
--------------------
122125

126+
Deprecated or removed
127+
---------------------
128+
129+
* The method `merge(combine::Callable, d::AbstractDict...)` is now deprecated to favor `mergewith` instead ([#59775]).
130+
123131
<!--- generated by NEWS-update.jl: -->

base/client.jl

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ end
484484
function run_std_repl(REPL::Module, quiet::Bool, banner::Symbol, history_file::Bool)
485485
term_env = get(ENV, "TERM", @static Sys.iswindows() ? "" : "dumb")
486486
term = REPL.Terminals.TTYTerminal(term_env, stdin, stdout, stderr)
487-
banner == :no || REPL.banner(term, short=banner==:short)
487+
banner == :no || REPL.banner(term, banner)
488488
if term.term_type == "dumb"
489489
repl = REPL.BasicREPL(term)
490490
quiet || @warn "Terminal not fully functional"
@@ -607,12 +607,26 @@ end
607607
function repl_main(_)
608608
opts = Base.JLOptions()
609609
interactiveinput = isa(stdin, Base.TTY)
610-
b = opts.banner
611-
auto = b == -1
612-
banner = b == 0 || (auto && !interactiveinput) ? :no :
613-
b == 1 || (auto && interactiveinput) ? :yes :
614-
:short # b == 2
615-
610+
bval = if opts.banner == -1 # Auto
611+
Int(interactiveinput)
612+
else
613+
opts.banner
614+
end
615+
# All the options produced by `jloptions.c`'s `case opt_banner`.
616+
# 0=off, 1=largest, ..., N=smallest
617+
banner = if bval == 0
618+
:no
619+
elseif bval == 1
620+
:full
621+
elseif bval == 2
622+
:narrow
623+
elseif bval == 3
624+
:short
625+
elseif bval == 4
626+
:tiny
627+
else # For type stability of `banner`
628+
:unreachable
629+
end
616630
quiet = (opts.quiet != 0)
617631
history_file = (opts.historyfile != 0)
618632
return run_main_repl(interactiveinput, quiet, banner, history_file)

base/deprecated.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,3 +566,9 @@ end
566566
to_power_type(x) = oftype(x*x, x)
567567

568568
# END 1.12 deprecations
569+
570+
# BEGIN 1.13 deprecations
571+
572+
@deprecate merge(combine::Callable, d::AbstractDict, others::AbstractDict...) mergewith(combine, d, others...)
573+
574+
# end 1.13 deprecations

base/initdefs.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,27 @@ function set_active_project(projfile::Union{AbstractString,Nothing})
371371
end
372372
end
373373

374+
"""
375+
active_manifest()
376+
active_manifest(project_file::AbstractString)
377+
378+
Return the path of the active manifest file, or the manifest file that would be used for a given `project_file`.
379+
380+
In a stacked environment (where multiple environments exist in the load path), this returns the manifest
381+
file for the primary (active) environment only, not the manifests from other environments in the stack.
382+
See the manual section on [Environment stacks](@ref) for more details on how stacked environments work.
383+
384+
See [`Project environments`](@ref project-environments) for details on the difference between a project and a manifest, and the naming
385+
options and their priority in package loading.
386+
387+
See also [`Base.active_project`](@ref), [`Base.set_active_project`](@ref).
388+
"""
389+
function active_manifest(project_file::Union{AbstractString,Nothing}=nothing; search_load_path::Bool=true)
390+
# If `project_file` was specified, use that, otherwise get the active project:
391+
project_file = !isnothing(project_file) ? project_file : active_project(search_load_path)
392+
project_file === nothing && return nothing
393+
return project_file_manifest_path(project_file)
394+
end
374395

375396
"""
376397
load_path()

base/loading.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,7 @@ function project_file_manifest_path(project_file::String)::Union{Nothing,String}
885885
manifest_path === missing || return manifest_path
886886
end
887887
dir = abspath(dirname(project_file))
888+
isfile_casesensitive(project_file) || return nothing
888889
d = parsed_toml(project_file)
889890
base_manifest = workspace_manifest(project_file)
890891
if base_manifest !== nothing

base/public.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public
5353
DL_LOAD_PATH,
5454
load_path,
5555
active_project,
56+
active_manifest,
5657

5758
# Reflection and introspection
5859
get_extension,

base/regex.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -649,17 +649,17 @@ replace_err(repl) = error("Bad replacement string: $repl")
649649
function _write_capture(io::IO, group::Int, str, r, re::RegexAndMatchData)
650650
len = PCRE.substring_length_bynumber(re.match_data, group)
651651
# in the case of an optional group that doesn't match, len == 0
652-
len == 0 && return
652+
len == 0 && return len
653653
ensureroom(io, len+1)
654654
PCRE.substring_copy_bynumber(re.match_data, group,
655655
pointer(io.data, io.ptr), len+1)
656656
io.ptr += len
657657
io.size = max(io.size, io.ptr - 1)
658-
nothing
658+
return len
659659
end
660660
function _write_capture(io::IO, group::Int, str, r, re)
661661
group == 0 || replace_err("pattern is not a Regex")
662-
return print(io, SubString(str, r))
662+
return write(io, SubString(str, r))
663663
end
664664

665665

@@ -673,12 +673,13 @@ function _replace(io, repl_s::SubstitutionString, str, r, re)
673673
repl = unescape_string(repl_s.string, KEEP_ESC)
674674
i = firstindex(repl)
675675
e = lastindex(repl)
676+
nb = 0
676677
while i <= e
677678
if repl[i] == SUB_CHAR
678679
next_i = nextind(repl, i)
679680
next_i > e && replace_err(repl)
680681
if repl[next_i] == SUB_CHAR
681-
write(io, SUB_CHAR)
682+
nb += write(io, SUB_CHAR)
682683
i = nextind(repl, next_i)
683684
elseif isdigit(repl[next_i])
684685
group = parse(Int, repl[next_i])
@@ -691,7 +692,7 @@ function _replace(io, repl_s::SubstitutionString, str, r, re)
691692
break
692693
end
693694
end
694-
_write_capture(io, group, str, r, re)
695+
nb += _write_capture(io, group, str, r, re)
695696
elseif repl[next_i] == GROUP_CHAR
696697
i = nextind(repl, next_i)
697698
if i > e || repl[i] != LBRACKET
@@ -713,16 +714,17 @@ function _replace(io, repl_s::SubstitutionString, str, r, re)
713714
else
714715
group = -1
715716
end
716-
_write_capture(io, group, str, r, re)
717+
nb += _write_capture(io, group, str, r, re)
717718
i = nextind(repl, i)
718719
else
719720
replace_err(repl)
720721
end
721722
else
722-
write(io, repl[i])
723+
nb += write(io, repl[i])
723724
i = nextind(repl, i)
724725
end
725726
end
727+
nb
726728
end
727729

728730
struct RegexMatchIterator{S <: AbstractString}

0 commit comments

Comments
 (0)