Skip to content

Commit f6f6b1c

Browse files
authored
make Type{Union{}} ismutationfree (JuliaLang#48417)
1 parent 8b9da8d commit f6f6b1c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/jltypes.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2204,6 +2204,7 @@ void jl_init_types(void) JL_GC_DISABLED
22042204
((jl_datatype_t*)jl_type_type)->cached_by_hash = 0;
22052205
jl_type_typename->wrapper = jl_new_struct(jl_unionall_type, tttvar, (jl_value_t*)jl_type_type);
22062206
jl_type_type = (jl_unionall_t*)jl_type_typename->wrapper;
2207+
((jl_datatype_t*)jl_type_type->body)->ismutationfree = 1;
22072208

22082209
jl_typeofbottom_type->super = jl_wrap_Type(jl_bottom_type);
22092210

@@ -2807,7 +2808,6 @@ void jl_init_types(void) JL_GC_DISABLED
28072808
jl_symbol_type->ismutationfree = jl_symbol_type->isidentityfree = 1;
28082809
jl_simplevector_type->ismutationfree = jl_simplevector_type->isidentityfree = 1;
28092810
jl_datatype_type->ismutationfree = 1;
2810-
((jl_datatype_t*)jl_type_type->body)->ismutationfree = 1;
28112811

28122812
// Technically not ismutationfree, but there's a separate system to deal
28132813
// with mutations for global state.

test/compiler/effects.jl

+3
Original file line numberDiff line numberDiff line change
@@ -740,3 +740,6 @@ end |> !Core.Compiler.is_consistent
740740
ImmutRef(x) = $(Expr(:new, :(ImmutRef{typeof(x)}), :x))
741741
end
742742
@test Core.Compiler.is_foldable(Base.infer_effects(ImmutRef, Tuple{Any}))
743+
744+
@test Base.ismutationfree(Type{Union{}})
745+
@test Core.Compiler.is_total(Base.infer_effects(typejoin, ()))

0 commit comments

Comments
 (0)