Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ This section lists changes that do not have deprecation warnings.
as `UnionAll` types instead of `DataType`s ([#18457]).

* `Union` types have two fields, `a` and `b`, instead of a single `types` field.
The empty type `Union{}` is represented by a singleton of type `BottomType` ([#18457]).
The empty type `Union{}` is represented by a singleton of type `TypeofBottom` ([#18457]).

* The type `NTuple{N}` now refers to tuples where every element has the same type
(since it is shorthand for `NTuple{N,T} where T`). To get the old behavior of matching
Expand Down
7 changes: 7 additions & 0 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,13 @@ generation specialization for that field.
"""
ANY

"""
Core.TypeofBottom

The singleton type containing only the value `Union{}`.
"""
Core.TypeofBottom

"""
DevNull

Expand Down
2 changes: 1 addition & 1 deletion base/serialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const TAGS = Any[
Module, #=UndefRefTag=#Symbol, Task, String, Float16,
SimpleVector, #=BackrefTag=#Symbol, Method, GlobalRef, UnionAll,

(), Bool, Any, :Any, Bottom, Core.BottomType, :reserved22, Type,
(), Bool, Any, :Any, Bottom, Core.TypeofBottom, :reserved22, Type,
:Array, :TypeVar, :Box,
:lambda, :body, :return, :call, Symbol("::"),
:(=), :null, :gotoifnot, :A, :B, :C, :M, :N, :T, :S, :X, :Y,
Expand Down
2 changes: 1 addition & 1 deletion base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function show(io::IO, x::Core.IntrinsicFunction)
print(io, unsafe_string(name))
end

show(io::IO, ::Core.BottomType) = print(io, "Union{}")
show(io::IO, ::Core.TypeofBottom) = print(io, "Union{}")

function show(io::IO, x::Union)
print(io, "Union")
Expand Down
8 changes: 4 additions & 4 deletions doc/src/devdocs/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ julia> dump(Array)
UnionAll
var: TypeVar
name: Symbol T
lb: Core.BottomType Union{}
lb: Core.TypeofBottom Union{}
ub: Any
body: UnionAll
var: TypeVar
name: Symbol N
lb: Core.BottomType Union{}
lb: Core.TypeofBottom Union{}
ub: Any
body: Array{T,N} <: DenseArray{T,N}
```
Expand Down Expand Up @@ -178,12 +178,12 @@ TypeName
wrapper: UnionAll
var: TypeVar
name: Symbol T
lb: Core.BottomType Union{}
lb: Core.TypeofBottom Union{}
ub: Any
body: UnionAll
var: TypeVar
name: Symbol N
lb: Core.BottomType Union{}
lb: Core.TypeofBottom Union{}
ub: Any
body: Array{T,N} <: DenseArray{T,N}
cache: SimpleVector
Expand Down
2 changes: 1 addition & 1 deletion src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ void jl_init_primitives(void)
add_builtin("TypeVar", (jl_value_t*)jl_tvar_type);
add_builtin("UnionAll", (jl_value_t*)jl_unionall_type);
add_builtin("Union", (jl_value_t*)jl_uniontype_type);
add_builtin("BottomType", (jl_value_t*)jl_bottomtype_type);
add_builtin("TypeofBottom", (jl_value_t*)jl_typeofbottom_type);
add_builtin("Tuple", (jl_value_t*)jl_anytuple_type);
add_builtin("Vararg", (jl_value_t*)jl_vararg_type);
add_builtin("SimpleVector", (jl_value_t*)jl_simplevector_type);
Expand Down
8 changes: 4 additions & 4 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,8 @@ static inline jl_cgval_t ghostValue(jl_value_t *typ)
{
if (typ == jl_bottom_type)
return jl_cgval_t(); // Undef{}
if (typ == (jl_value_t*)jl_bottomtype_type) {
// normalize BottomType to Type{Union{}}
if (typ == (jl_value_t*)jl_typeofbottom_type) {
// normalize TypeofBottom to Type{Union{}}
typ = (jl_value_t*)jl_wrap_Type(jl_bottom_type);
}
if (jl_is_type_type(typ)) {
Expand Down Expand Up @@ -870,8 +870,8 @@ static void jl_rethrow_with_add(const char *fmt, ...)
// given a value marked with type `v.typ`, compute the mapping and/or boxing to return a value of type `typ`
static jl_cgval_t convert_julia_type(const jl_cgval_t &v, jl_value_t *typ, jl_codectx_t *ctx, bool needsroot = true)
{
if (typ == (jl_value_t*)jl_bottomtype_type)
return ghostValue(typ); // normalize BottomType to Type{Union{}}
if (typ == (jl_value_t*)jl_typeofbottom_type)
return ghostValue(typ); // normalize TypeofBottom to Type{Union{}}
if (v.typ == typ || v.typ == jl_bottom_type || jl_egal(v.typ, typ))
return v; // fast-path
Type *T = julia_type_to_llvm(typ);
Expand Down
4 changes: 2 additions & 2 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -3099,7 +3099,7 @@ void jl_init_serializer(void)
jl_voidpointer_type, jl_newvarnode_type, jl_abstractstring_type,
jl_array_symbol_type, jl_anytuple_type, jl_tparam0(jl_anytuple_type),
jl_emptytuple_type, jl_array_uint8_type, jl_symbol_type->name,
jl_ssavalue_type->name, jl_tuple_typename, jl_code_info_type, jl_bottomtype_type,
jl_ssavalue_type->name, jl_tuple_typename, jl_code_info_type, jl_typeofbottom_type,
((jl_datatype_t*)jl_unwrap_unionall((jl_value_t*)jl_ref_type))->name,
jl_pointer_typename, jl_simplevector_type->name, jl_datatype_type->name,
jl_uniontype_type->name, jl_array_typename, jl_expr_type->name,
Expand All @@ -3112,7 +3112,7 @@ void jl_init_serializer(void)
jl_abstractslot_type->name, jl_slotnumber_type->name, jl_unionall_type->name,
jl_intrinsic_type->name, jl_task_type->name, jl_labelnode_type->name,
jl_linenumbernode_type->name, jl_builtin_type->name, jl_gotonode_type->name,
jl_quotenode_type->name, jl_globalref_type->name, jl_bottomtype_type->name,
jl_quotenode_type->name, jl_globalref_type->name, jl_typeofbottom_type->name,
jl_string_type->name, jl_abstractstring_type->name,

ptls->root_task,
Expand Down
8 changes: 4 additions & 4 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jl_datatype_t *jl_datatype_type;
jl_datatype_t *jl_function_type;
jl_datatype_t *jl_builtin_type;

jl_datatype_t *jl_bottomtype_type;
jl_datatype_t *jl_typeofbottom_type;
jl_value_t *jl_bottom_type;
jl_unionall_t *jl_abstractarray_type;
jl_unionall_t *jl_densearray_type;
Expand Down Expand Up @@ -1616,10 +1616,10 @@ void jl_init_types(void)
jl_void_type->instance = jl_nothing;

jl_datatype_t *type_type = (jl_datatype_t*)jl_type_type;
jl_bottomtype_type = jl_new_datatype(jl_symbol("BottomType"), type_type, jl_emptysvec,
jl_typeofbottom_type = jl_new_datatype(jl_symbol("TypeofBottom"), type_type, jl_emptysvec,
jl_emptysvec, jl_emptysvec, 0, 0, 0);
jl_bottom_type = jl_new_struct(jl_bottomtype_type);
jl_bottomtype_type->instance = jl_bottom_type;
jl_bottom_type = jl_new_struct(jl_typeofbottom_type);
jl_typeofbottom_type->instance = jl_bottom_type;

jl_uniontype_type = jl_new_datatype(jl_symbol("Union"), type_type, jl_emptysvec,
jl_svec(2, jl_symbol("a"), jl_symbol("b")),
Expand Down
4 changes: 2 additions & 2 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ typedef struct {
// constants and type objects -------------------------------------------------

// kinds
extern JL_DLLEXPORT jl_datatype_t *jl_bottomtype_type;
extern JL_DLLEXPORT jl_datatype_t *jl_typeofbottom_type;
extern JL_DLLEXPORT jl_datatype_t *jl_datatype_type;
extern JL_DLLEXPORT jl_datatype_t *jl_uniontype_type;
extern JL_DLLEXPORT jl_datatype_t *jl_unionall_type;
Expand Down Expand Up @@ -873,7 +873,7 @@ JL_DLLEXPORT int jl_subtype(jl_value_t *a, jl_value_t *b);
STATIC_INLINE int jl_is_kind(jl_value_t *v)
{
return (v==(jl_value_t*)jl_uniontype_type || v==(jl_value_t*)jl_datatype_type ||
v==(jl_value_t*)jl_unionall_type || v==(jl_value_t*)jl_bottomtype_type);
v==(jl_value_t*)jl_unionall_type || v==(jl_value_t*)jl_typeofbottom_type);
}

STATIC_INLINE int jl_is_type(jl_value_t *v)
Expand Down
2 changes: 1 addition & 1 deletion src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ static jl_value_t *intersect_type_type(jl_value_t *x, jl_value_t *y, jl_stenv_t
if (!jl_is_typevar(p0))
return (jl_typeof(p0) == y) ? x : jl_bottom_type;
if (!jl_is_kind(y)) return jl_bottom_type;
if (y == (jl_value_t*)jl_bottomtype_type && ((jl_tvar_t*)p0)->lb == jl_bottom_type)
if (y == (jl_value_t*)jl_typeofbottom_type && ((jl_tvar_t*)p0)->lb == jl_bottom_type)
return (jl_value_t*)jl_wrap_Type(jl_bottom_type);
if (((jl_tvar_t*)p0)->ub == (jl_value_t*)jl_any_type)
return y;
Expand Down
2 changes: 1 addition & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4769,7 +4769,7 @@ end
x::Array{T} where T<:Integer
end

let a = Array{Core.BottomType, 1}(2)
let a = Array{Core.TypeofBottom, 1}(2)
@test a[1] == Union{}
@test a == [Union{}, Union{}]
end
4 changes: 2 additions & 2 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,8 @@ function test_intersection()
@test typeintersect(Union{DataType,Int}, Type) === DataType
@test typeintersect(Union{DataType,Int}, Type{T} where T) === DataType

# since BottomType is a singleton we can deduce its intersection with Type{...}
@testintersect(Core.BottomType, (Type{T} where T<:Tuple), Type{Union{}})
# since TypeofBottom is a singleton we can deduce its intersection with Type{...}
@testintersect(Core.TypeofBottom, (Type{T} where T<:Tuple), Type{Union{}})

@testintersect((Type{Tuple{Vararg{T}}} where T), Type{Tuple}, Bottom)
@testintersect(Tuple{Type{S}, Tuple{Any, Vararg{Any}}} where S<:Tuple{Any, Vararg{Any}},
Expand Down