Skip to content

Commit 87ef4b3

Browse files
committed
Add Compiler._verify_trim_world_age for better printing
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{Char, ?, ?}, xs::Any, size_info::Dict{Char, Int64}) @ OMEinsum ~/.julia/dev/OMEinsum/src/einsequence.jl:269 ... ``` After: ``` [1] get_size_dict!(ne::StaticNestedEinsum{Char, nothing, ('j','k','l')}, xs::Any, size_info::Dict{Char, Int64}) @ OMEinsum ~/.julia/dev/OMEinsum/src/einsequence.jl:269 ... ```
1 parent df91352 commit 87ef4b3

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
@@ -1641,7 +1641,8 @@ function typeinf_ext_toplevel(methods::Vector{Any}, worlds::Vector{UInt}, trim_m
16411641
return codeinfos
16421642
end
16431643

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

16461647
function return_type(@nospecialize(f), t::DataType) # this method has a special tfunc
16471648
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)