Skip to content

Commit ee47bd4

Browse files
authored
Add Compiler._verify_trim_world_age for better printing (#58407)
The `juliac-buildscript` is quite aggressive in how it modifies type printing, so caching the pre-buildscript world like this allows us to print stacktraces in their usual fidelity. Before: ``` [1] get_size_dict!(ne::StaticNestedEinsum{?, ?}, xs::Any, size_info::Dict{Char, Int64}) @ OMEinsum ~/.julia/dev/OMEinsum/src/einsequence.jl:269 ... ``` After: ``` [1] get_size_dict!(ne::StaticNestedEinsum{nothing, ('j','k','l')}, xs::Any, size_info::Dict{Char, Int64}) @ OMEinsum ~/.julia/dev/OMEinsum/src/einsequence.jl:269 ... ```
2 parents 3fc2a15 + 87ef4b3 commit ee47bd4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Compiler/src/typeinfer.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,8 @@ function typeinf_ext_toplevel(methods::Vector{Any}, worlds::Vector{UInt}, trim_m
16831683
return codeinfos
16841684
end
16851685

1686-
verify_typeinf_trim(codeinfos::Vector{Any}, onlywarn::Bool) = invokelatest(verify_typeinf_trim, stdout, codeinfos, onlywarn)
1686+
const _verify_trim_world_age = RefValue{UInt}(typemax(UInt))
1687+
verify_typeinf_trim(codeinfos::Vector{Any}, onlywarn::Bool) = Core._call_in_world(_verify_trim_world_age[], verify_typeinf_trim, stdout, codeinfos, onlywarn)
16871688

16881689
function return_type(@nospecialize(f), t::DataType) # this method has a special tfunc
16891690
world = tls_world_age()

contrib/juliac-buildscript.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ inputfile = ARGS[1]
44
output_type = ARGS[2]
55
add_ccallables = ARGS[3] == "true"
66

7+
# Run the verifier in the current world (before modifications), so that error
8+
# messages and types print in their usual way.
9+
Core.Compiler._verify_trim_world_age[] = Base.get_world_counter()
10+
711
# Initialize some things not usually initialized when output is requested
812
Sys.__init__()
913
Base.init_depot_path()

0 commit comments

Comments
 (0)