Skip to content

Commit bbf89d9

Browse files
authored
Merge branch 'master' into ms/last_incremental_sweep
2 parents 831ac70 + 0da46e2 commit bbf89d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1354
-456
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ endif
365365
# Remove various files which should not be installed
366366
-rm -f $(DESTDIR)$(datarootdir)/julia/base/version_git.sh
367367
-rm -f $(DESTDIR)$(datarootdir)/julia/test/Makefile
368+
-rm -f $(DESTDIR)$(datarootdir)/julia/base/*/source-extracted
369+
-rm -f $(DESTDIR)$(datarootdir)/julia/base/*/build-configured
370+
-rm -f $(DESTDIR)$(datarootdir)/julia/base/*/build-compiled
371+
-rm -f $(DESTDIR)$(datarootdir)/julia/base/*/build-checked
368372
-rm -f $(DESTDIR)$(datarootdir)/julia/stdlib/$(VERSDIR)/*/source-extracted
369373
-rm -f $(DESTDIR)$(datarootdir)/julia/stdlib/$(VERSDIR)/*/build-configured
370374
-rm -f $(DESTDIR)$(datarootdir)/julia/stdlib/$(VERSDIR)/*/build-compiled

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Julia v1.10 Release Notes
44
New language features
55
---------------------
66

7+
* JuliaSyntax.jl is now used as the default parser, providing better diagnostics and faster
8+
parsing. Set environment variable `JULIA_USE_NEW_PARSER` to `0` to switch back to the old
9+
parser if necessary (and if you find this necessary, please file an issue) ([#46372]).
710
* `` (U+297A, `\leftarrowsubset`) and `` (U+2977, `\leftarrowless`)
811
may now be used as binary operators with arrow precedence. ([#45962])
912

base/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
/version_git.jl
99
/version_git.jl.phony
1010
/userimg.jl
11+
/JuliaSyntax

base/Base.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ a_method_to_overwrite_in_test() = inferencebarrier(1)
489489
include(mod::Module, _path::AbstractString) = _include(identity, mod, _path)
490490
include(mapexpr::Function, mod::Module, _path::AbstractString) = _include(mapexpr, mod, _path)
491491

492+
# External libraries vendored into Base
493+
Core.println("JuliaSyntax/src/JuliaSyntax.jl")
494+
include(@__MODULE__, "JuliaSyntax/src/JuliaSyntax.jl")
495+
492496
end_base_include = time_ns()
493497

494498
const _sysimage_modules = PkgId[]
@@ -600,6 +604,9 @@ function __init__()
600604
_require_world_age[] = get_world_counter()
601605
# Prevent spawned Julia process from getting stuck waiting on Tracy to connect.
602606
delete!(ENV, "JULIA_WAIT_FOR_TRACY")
607+
if get_bool_env("JULIA_USE_NEW_PARSER", true) === true
608+
JuliaSyntax.enable_in_core!()
609+
end
603610
nothing
604611
end
605612

base/boot.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,9 +825,11 @@ Integer(x::Union{Float16, Float32, Float64}) = Int(x)
825825
# `_parse` must return an `svec` containing an `Expr` and the new offset as an
826826
# `Int`.
827827
#
828-
# The internal jl_parse which will call into Core._parse if not `nothing`.
828+
# The internal jl_parse will call into Core._parse if not `nothing`.
829829
_parse = nothing
830830

831+
_setparser!(parser) = setglobal!(Core, :_parse, parser)
832+
831833
# support for deprecated uses of internal _apply function
832834
_apply(x...) = Core._apply_iterate(Main.Base.iterate, x...)
833835

base/client.jl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,7 @@ parse_input_line(s::AbstractString) = parse_input_line(String(s))
202202
# detect the reason which caused an :incomplete expression
203203
# from the error message
204204
# NOTE: the error messages are defined in src/julia-parser.scm
205-
incomplete_tag(ex) = :none
206-
function incomplete_tag(ex::Expr)
207-
Meta.isexpr(ex, :incomplete) || return :none
208-
msg = ex.args[1]
205+
function fl_incomplete_tag(msg::AbstractString)
209206
occursin("string", msg) && return :string
210207
occursin("comment", msg) && return :comment
211208
occursin("requires end", msg) && return :block
@@ -214,6 +211,20 @@ function incomplete_tag(ex::Expr)
214211
return :other
215212
end
216213

214+
incomplete_tag(ex) = :none
215+
function incomplete_tag(ex::Expr)
216+
if ex.head !== :incomplete
217+
return :none
218+
elseif isempty(ex.args)
219+
return :other
220+
elseif ex.args[1] isa String
221+
return fl_incomplete_tag(ex.args[1])
222+
else
223+
return incomplete_tag(ex.args[1])
224+
end
225+
end
226+
incomplete_tag(exc::Meta.ParseError) = incomplete_tag(exc.detail)
227+
217228
function exec_options(opts)
218229
quiet = (opts.quiet != 0)
219230
startup = (opts.startupfile != 2)

base/compiler/abstractinterpretation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ function abstract_apply(interp::AbstractInterpreter, argtypes::Vector{Any}, si::
15881588
call = abstract_call(interp, ArgInfo(nothing, ct), si, sv, max_methods)
15891589
seen += 1
15901590
push!(retinfos, ApplyCallInfo(call.info, arginfo))
1591-
res = tmerge(res, call.rt)
1591+
res = tmerge(typeinf_lattice(interp), res, call.rt)
15921592
effects = merge_effects(effects, call.effects)
15931593
if bail_out_apply(interp, InferenceLoopState(ct, res, effects), sv)
15941594
add_remark!(interp, sv, "_apply_iterate inference reached maximally imprecise information. Bailing on.")

base/compiler/compiler.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ include("compiler/bootstrap.jl")
171171
ccall(:jl_set_typeinf_func, Cvoid, (Any,), typeinf_ext_toplevel)
172172

173173
include("compiler/parsing.jl")
174-
Core.eval(Core, :(_parse = Compiler.fl_parse))
174+
Core._setparser!(fl_parse)
175175

176176
end # baremodule Compiler
177177
))

base/compiler/typelimits.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ function tmerge(lattice::OptimizerLattice, @nospecialize(typea), @nospecialize(t
385385

386386
# type-lattice for MaybeUndef wrapper
387387
if isa(typea, MaybeUndef) || isa(typeb, MaybeUndef)
388-
return MaybeUndef(tmerge(
388+
return MaybeUndef(tmerge(widenlattice(lattice),
389389
isa(typea, MaybeUndef) ? typea.typ : typea,
390390
isa(typeb, MaybeUndef) ? typeb.typ : typeb))
391391
end

base/errorshow.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ show_index(io::IO, x::LogicalIndex) = summary(io, x.mask)
3535
show_index(io::IO, x::OneTo) = print(io, "1:", x.stop)
3636
show_index(io::IO, x::Colon) = print(io, ':')
3737

38+
function showerror(io::IO, ex::Meta.ParseError)
39+
if isnothing(ex.detail)
40+
print(io, "ParseError(", repr(ex.msg), ")")
41+
else
42+
showerror(io, ex.detail)
43+
end
44+
end
3845

3946
function showerror(io::IO, ex::BoundsError)
4047
print(io, "BoundsError")
@@ -243,7 +250,7 @@ function showerror(io::IO, ex::MethodError)
243250
ft = typeof(f)
244251
arg_types_param = arg_types_param[3:end]
245252
kwargs = pairs(ex.args[1])
246-
ex = MethodError(f, ex.args[3:end::Int])
253+
ex = MethodError(f, ex.args[3:end::Int], ex.world)
247254
end
248255
name = ft.name.mt.name
249256
if f === Base.convert && length(arg_types_param) == 2 && !is_arg_types
@@ -490,7 +497,11 @@ function show_method_candidates(io::IO, ex::MethodError, @nospecialize kwargs=()
490497
if !((min(length(t_i), length(sig)) == 0) && k==1)
491498
print(iob, ", ")
492499
end
493-
if get(io, :color, false)::Bool
500+
if k == 1 && Base.isvarargtype(sigtype)
501+
# There wasn't actually a mismatch - the method match failed for
502+
# some other reason, e.g. world age. Just print the sigstr.
503+
print(iob, sigstr...)
504+
elseif get(io, :color, false)::Bool
494505
let sigstr=sigstr
495506
Base.with_output_color(Base.error_color(), iob) do iob
496507
print(iob, "::", sigstr...)

0 commit comments

Comments
 (0)