From f6f6b1cfb06a548728d2c0b987f0695902d611a1 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Sat, 28 Jan 2023 10:55:02 -0300 Subject: [PATCH] make `Type{Union{}}` `ismutationfree` (#48417) --- src/jltypes.c | 2 +- test/compiler/effects.jl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/jltypes.c b/src/jltypes.c index 9428bf6a91092..d9f50d67d3f73 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -2204,6 +2204,7 @@ void jl_init_types(void) JL_GC_DISABLED ((jl_datatype_t*)jl_type_type)->cached_by_hash = 0; jl_type_typename->wrapper = jl_new_struct(jl_unionall_type, tttvar, (jl_value_t*)jl_type_type); jl_type_type = (jl_unionall_t*)jl_type_typename->wrapper; + ((jl_datatype_t*)jl_type_type->body)->ismutationfree = 1; jl_typeofbottom_type->super = jl_wrap_Type(jl_bottom_type); @@ -2807,7 +2808,6 @@ void jl_init_types(void) JL_GC_DISABLED jl_symbol_type->ismutationfree = jl_symbol_type->isidentityfree = 1; jl_simplevector_type->ismutationfree = jl_simplevector_type->isidentityfree = 1; jl_datatype_type->ismutationfree = 1; - ((jl_datatype_t*)jl_type_type->body)->ismutationfree = 1; // Technically not ismutationfree, but there's a separate system to deal // with mutations for global state. diff --git a/test/compiler/effects.jl b/test/compiler/effects.jl index 42e370c922ef6..656ac9268dcb4 100644 --- a/test/compiler/effects.jl +++ b/test/compiler/effects.jl @@ -740,3 +740,6 @@ end |> !Core.Compiler.is_consistent ImmutRef(x) = $(Expr(:new, :(ImmutRef{typeof(x)}), :x)) end @test Core.Compiler.is_foldable(Base.infer_effects(ImmutRef, Tuple{Any})) + +@test Base.ismutationfree(Type{Union{}}) +@test Core.Compiler.is_total(Base.infer_effects(typejoin, ()))