Skip to content

Commit fd87104

Browse files
committed
Fix various test issues
1 parent ba34a49 commit fd87104

File tree

5 files changed

+42
-39
lines changed

5 files changed

+42
-39
lines changed

base/opaque_closure.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ end
3939

4040
# OpaqueClosure construction from pre-inferred CodeInfo/IRCode
4141
using Core: CodeInfo, SSAValue
42-
using Base.Compiler: IRCode
42+
using Base: Compiler
43+
using .Compiler: IRCode
4344

4445
function compute_ir_rettype(ir::IRCode)
4546
rt = Union{}

base/reflection.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,23 +534,23 @@ end
534534

535535
function _builtin_return_type(interp,
536536
@nospecialize(f::Core.Builtin), @nospecialize(types))
537-
Compiler = typename(typeof(interp))
537+
Compiler = typename(typeof(interp)).module
538538
argtypes = Any[to_tuple_type(types).parameters...]
539539
rt = Compiler.builtin_tfunction(interp, f, argtypes, nothing)
540540
return Compiler.widenconst(rt)
541541
end
542542

543543
function _builtin_effects(interp,
544544
@nospecialize(f::Core.Builtin), @nospecialize(types))
545-
Compiler = typename(typeof(interp))
545+
Compiler = typename(typeof(interp)).module
546546
argtypes = Any[to_tuple_type(types).parameters...]
547547
rt = Compiler.builtin_tfunction(interp, f, argtypes, nothing)
548548
return Compiler.builtin_effects(Compiler.typeinf_lattice(interp), f, argtypes, rt)
549549
end
550550

551551
function _builtin_exception_type(interp,
552552
@nospecialize(f::Core.Builtin), @nospecialize(types))
553-
Compiler = typename(typeof(interp))
553+
Compiler = typename(typeof(interp)).module
554554
effects = _builtin_effects(interp, f, types)
555555
return Compiler.is_nothrow(effects) ? Union{} : Any
556556
end
@@ -612,7 +612,7 @@ function return_types(@nospecialize(f), @nospecialize(types=default_tt(f));
612612
interp=Compiler.NativeInterpreter(world))
613613
check_generated_context(world)
614614
if isa(f, Core.OpaqueClosure)
615-
_, rt = only(code_typed_opaque_closure(Compiler, f, types))
615+
_, rt = only(code_typed_opaque_closure(f, types; Compiler))
616616
return Any[rt]
617617
elseif isa(f, Core.Builtin)
618618
return Any[_builtin_return_type(interp, f, types)]

stdlib/Compiler/src/Compiler.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ using Base: Ordering, vect, EffectsOverride, BitVector, @_gc_preserve_begin, @_g
5959
specialize_method, hasintersect, is_nospecializeinfer, is_nospecialized,
6060
get_nospecializeinfer_sig, tls_world_age, uniontype_layout, kwerr,
6161
moduleroot, is_file_tracked, decode_effects_override, lookup_binding_partition,
62-
is_some_imported, binding_kind, is_some_guard, is_some_const_binding, partition_restriction
62+
is_some_imported, binding_kind, is_some_guard, is_some_const_binding, partition_restriction,
63+
BINDING_KIND_GLOBAL
6364
using Base.Order
6465
import Base: getindex, setindex!, length, iterate, push!, isempty, first, convert, ==,
6566
copy, popfirst!, in, haskey, resize!, copy!, append!, last, get!, size,

stdlib/InteractiveUtils/src/codeview.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ function _dump_function(@nospecialize(f), @nospecialize(t), native::Bool, wrappe
239239
if !isa(f, Core.OpaqueClosure)
240240
src = Base.Compiler.typeinf_code(Base.Compiler.NativeInterpreter(world), mi, true)
241241
else
242-
src, rt = Base.get_oc_code_rt(f, tt, true)
242+
src, rt = Base.get_oc_code_rt(Base.Compiler, f, tt, true)
243243
end
244244
src isa Core.CodeInfo || error("failed to infer source for $mi")
245245
str = _dump_function_native_assembly(mi, src, wrapper, syntax, debuginfo, binary, raw, params)
@@ -248,7 +248,7 @@ function _dump_function(@nospecialize(f), @nospecialize(t), native::Bool, wrappe
248248
if !isa(f, Core.OpaqueClosure)
249249
src = Base.Compiler.typeinf_code(Base.Compiler.NativeInterpreter(world), mi, true)
250250
else
251-
src, rt = Base.get_oc_code_rt(f, tt, true)
251+
src, rt = Base.get_oc_code_rt(Base.Compiler, f, tt, true)
252252
end
253253
src isa Core.CodeInfo || error("failed to infer source for $mi")
254254
str = _dump_function_llvm(mi, src, wrapper, !raw, dump_module, optimize, debuginfo, params)

test/compiler/inference.jl

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ let nfields_tfunc(@nospecialize xs...) =
15351535
@test sizeof_nothrow(String)
15361536
@test !sizeof_nothrow(Type{String})
15371537
@test sizeof_tfunc(Type{Union{Int64, Int32}}) == Const(Core.sizeof(Union{Int64, Int32}))
1538-
let PT = Core.PartialStruct(Cpre.Compiler.fallback_lattice, Tuple{Int64,UInt64}, Any[Const(10), UInt64])
1538+
let PT = Core.PartialStruct(Base.Compiler.fallback_lattice, Tuple{Int64,UInt64}, Any[Const(10), UInt64])
15391539
@test sizeof_tfunc(PT) === Const(16)
15401540
@test nfields_tfunc(PT) === Const(2)
15411541
@test sizeof_nothrow(PT)
@@ -3381,9 +3381,9 @@ struct FooPartial
33813381
b::Int
33823382
c::Int
33833383
end
3384-
let PT1 = PartialStruct(FooPartial, Any[Const(1), Const(2), Int]),
3385-
PT2 = PartialStruct(FooPartial, Any[Const(1), Int, Int]),
3386-
PT3 = PartialStruct(FooPartial, Any[Const(1), Int, Const(3)])
3384+
let PT1 = PartialStruct(Base.Compiler.fallback_lattice, FooPartial, Any[Const(1), Const(2), Int]),
3385+
PT2 = PartialStruct(Base.Compiler.fallback_lattice, FooPartial, Any[Const(1), Int, Int]),
3386+
PT3 = PartialStruct(Base.Compiler.fallback_lattice, FooPartial, Any[Const(1), Int, Const(3)])
33873387

33883388
@test PT1 PT2
33893389
@test !(PT1 PT3) && !(PT2 PT1)
@@ -4635,67 +4635,67 @@ end
46354635
@testset "issue #43784" begin
46364636
= Core.Compiler.partialorder(Core.Compiler.fallback_lattice)
46374637
= Core.Compiler.join(Core.Compiler.fallback_lattice)
4638+
𝕃 = Core.Compiler.fallback_lattice
46384639
Const, PartialStruct = Core.Const, Core.PartialStruct
4639-
46404640
let init = Base.ImmutableDict{Any,Any}()
46414641
a = Const(init)
4642-
b = PartialStruct(typeof(init), Any[Const(init), Any, Any])
4642+
b = PartialStruct(𝕃, typeof(init), Any[Const(init), Any, Any])
46434643
c = a b
46444644
@test a c && b c
46454645
@test c === typeof(init)
46464646
end
46474647
let init = Base.ImmutableDict{Any,Any}(1,2)
46484648
a = Const(init)
4649-
b = PartialStruct(typeof(init), Any[Const(getfield(init,1)), Any, Any])
4649+
b = PartialStruct(𝕃, typeof(init), Any[Const(getfield(init,1)), Any, Any])
46504650
c = a b
46514651
@test a c && b c
46524652
@test c isa PartialStruct
46534653
@test length(c.fields) == 3
46544654
end
46554655
let init = Base.ImmutableDict{Number,Number}()
46564656
a = Const(init)
4657-
b = PartialStruct(typeof(init), Any[Const(init), Number, ComplexF64])
4657+
b = PartialStruct(𝕃, typeof(init), Any[Const(init), Number, ComplexF64])
46584658
c = a b
46594659
@test a c && b c
46604660
@test c === typeof(init)
46614661
end
46624662
let init = Base.ImmutableDict{Number,Number}()
4663-
a = PartialStruct(typeof(init), Any[Const(init), ComplexF64, ComplexF64])
4664-
b = PartialStruct(typeof(init), Any[Const(init), Number, ComplexF64])
4663+
a = PartialStruct(𝕃, typeof(init), Any[Const(init), ComplexF64, ComplexF64])
4664+
b = PartialStruct(𝕃, typeof(init), Any[Const(init), Number, ComplexF64])
46654665
c = a b
46664666
@test a c && b c
46674667
@test c isa PartialStruct
46684668
@test c.fields[2] === Number
46694669
@test c.fields[3] === ComplexF64
46704670
end
46714671
let init = Base.ImmutableDict{Number,Number}()
4672-
a = PartialStruct(typeof(init), Any[Const(init), ComplexF64, ComplexF64])
4673-
b = PartialStruct(typeof(init), Any[Const(init), ComplexF32, Union{ComplexF32,ComplexF64}])
4672+
a = PartialStruct(𝕃, typeof(init), Any[Const(init), ComplexF64, ComplexF64])
4673+
b = PartialStruct(𝕃, typeof(init), Any[Const(init), ComplexF32, Union{ComplexF32,ComplexF64}])
46744674
c = a b
46754675
@test a c && b c
46764676
@test c isa PartialStruct
46774677
@test c.fields[2] === Complex
46784678
@test c.fields[3] === Complex
46794679
end
46804680
let T = Base.ImmutableDict{Number,Number}
4681-
a = PartialStruct(T, Any[T])
4682-
b = PartialStruct(T, Any[T, Number, Number])
4681+
a = PartialStruct(𝕃, T, Any[T])
4682+
b = PartialStruct(𝕃, T, Any[T, Number, Number])
46834683
@test b a
46844684
c = a b
46854685
@test a c && b c
46864686
@test c isa PartialStruct
46874687
@test length(c.fields) == 1
46884688
end
46894689
let T = Base.ImmutableDict{Number,Number}
4690-
a = PartialStruct(T, Any[T])
4690+
a = PartialStruct(𝕃, T, Any[T])
46914691
b = Const(T())
46924692
c = a b
46934693
@test a c && b c
46944694
@test c === T
46954695
end
46964696
let T = Base.ImmutableDict{Number,Number}
46974697
a = Const(T())
4698-
b = PartialStruct(T, Any[T])
4698+
b = PartialStruct(𝕃, T, Any[T])
46994699
c = a b
47004700
@test a c && b c
47014701
@test c === T
@@ -4742,22 +4742,23 @@ end
47424742

47434743
let = Core.Compiler.partialorder(Core.Compiler.fallback_lattice)
47444744
= Core.Compiler.join(Core.Compiler.fallback_lattice)
4745+
𝕃 = Core.Compiler.fallback_lattice
47454746
Const, PartialStruct = Core.Const, Core.PartialStruct
47464747

4747-
@test (Const((1,2)) PartialStruct(Tuple{Int,Int}, Any[Const(1),Int]))
4748-
@test !(Const((1,2)) PartialStruct(Tuple{Int,Int,Int}, Any[Const(1),Int,Int]))
4749-
@test !(Const((1,2,3)) PartialStruct(Tuple{Int,Int}, Any[Const(1),Int]))
4750-
@test (Const((1,2,3)) PartialStruct(Tuple{Int,Int,Int}, Any[Const(1),Int,Int]))
4751-
@test (Const((1,2)) PartialStruct(Tuple{Int,Vararg{Int}}, Any[Const(1),Vararg{Int}]))
4752-
@test (Const((1,2)) PartialStruct(Tuple{Int,Int,Vararg{Int}}, Any[Const(1),Int,Vararg{Int}])) broken=true
4753-
@test (Const((1,2,3)) PartialStruct(Tuple{Int,Int,Vararg{Int}}, Any[Const(1),Int,Vararg{Int}]))
4754-
@test !(PartialStruct(Tuple{Int,Int}, Any[Const(1),Int]) Const((1,2)))
4755-
@test !(PartialStruct(Tuple{Int,Int,Int}, Any[Const(1),Int,Int]) Const((1,2)))
4756-
@test !(PartialStruct(Tuple{Int,Int}, Any[Const(1),Int]) Const((1,2,3)))
4757-
@test !(PartialStruct(Tuple{Int,Int,Int}, Any[Const(1),Int,Int]) Const((1,2,3)))
4758-
@test !(PartialStruct(Tuple{Int,Vararg{Int}}, Any[Const(1),Vararg{Int}]) Const((1,2)))
4759-
@test !(PartialStruct(Tuple{Int,Int,Vararg{Int}}, Any[Const(1),Int,Vararg{Int}]) Const((1,2)))
4760-
@test !(PartialStruct(Tuple{Int,Int,Vararg{Int}}, Any[Const(1),Int,Vararg{Int}]) Const((1,2,3)))
4748+
@test (Const((1,2)) PartialStruct(𝕃, Tuple{Int,Int}, Any[Const(1),Int]))
4749+
@test !(Const((1,2)) PartialStruct(𝕃, Tuple{Int,Int,Int}, Any[Const(1),Int,Int]))
4750+
@test !(Const((1,2,3)) PartialStruct(𝕃, Tuple{Int,Int}, Any[Const(1),Int]))
4751+
@test (Const((1,2,3)) PartialStruct(𝕃, Tuple{Int,Int,Int}, Any[Const(1),Int,Int]))
4752+
@test (Const((1,2)) PartialStruct(𝕃, Tuple{Int,Vararg{Int}}, Any[Const(1),Vararg{Int}]))
4753+
@test (Const((1,2)) PartialStruct(𝕃, Tuple{Int,Int,Vararg{Int}}, Any[Const(1),Int,Vararg{Int}])) broken=true
4754+
@test (Const((1,2,3)) PartialStruct(𝕃, Tuple{Int,Int,Vararg{Int}}, Any[Const(1),Int,Vararg{Int}]))
4755+
@test !(PartialStruct(𝕃, Tuple{Int,Int}, Any[Const(1),Int]) Const((1,2)))
4756+
@test !(PartialStruct(𝕃, Tuple{Int,Int,Int}, Any[Const(1),Int,Int]) Const((1,2)))
4757+
@test !(PartialStruct(𝕃, Tuple{Int,Int}, Any[Const(1),Int]) Const((1,2,3)))
4758+
@test !(PartialStruct(𝕃, Tuple{Int,Int,Int}, Any[Const(1),Int,Int]) Const((1,2,3)))
4759+
@test !(PartialStruct(𝕃, Tuple{Int,Vararg{Int}}, Any[Const(1),Vararg{Int}]) Const((1,2)))
4760+
@test !(PartialStruct(𝕃, Tuple{Int,Int,Vararg{Int}}, Any[Const(1),Int,Vararg{Int}]) Const((1,2)))
4761+
@test !(PartialStruct(𝕃, Tuple{Int,Int,Vararg{Int}}, Any[Const(1),Int,Vararg{Int}]) Const((1,2,3)))
47614762

47624763
t = Const((false, false)) Const((false, true))
47634764
@test t isa PartialStruct && length(t.fields) == 2 && t.fields[1] === Const(false)
@@ -4899,7 +4900,7 @@ let src = code_typed1() do
48994900
end
49004901

49014902
# Test that Const ⊑ PartialStruct respects vararg
4902-
@test Const((1,2)) PartialStruct(Tuple{Vararg{Int}}, [Const(1), Vararg{Int}])
4903+
@test Const((1,2)) PartialStruct(Core.Compiler.fallback_lattice, Tuple{Vararg{Int}}, [Const(1), Vararg{Int}])
49034904

49044905
# Test that semi-concrete interpretation doesn't break on functions with while loops in them.
49054906
Base.@assume_effects :consistent :effect_free :terminates_globally function pure_annotated_loop(x::Int, y::Int)

0 commit comments

Comments
 (0)