@@ -650,7 +650,7 @@ static Type *_julia_type_to_llvm(jl_codegen_params_t *ctx, LLVMContext &ctxt, jl
650650{
651651 // this function converts a Julia Type into the equivalent LLVM type
652652 if (isboxed) *isboxed = false ;
653- if (jt == (jl_value_t *)jl_bottom_type)
653+ if (jt == (jl_value_t *)jl_bottom_type || jt == ( jl_value_t *)jl_typeofbottom_type || jt == ( jl_value_t *)jl_typeofbottom_type-> super )
654654 return getVoidTy (ctxt);
655655 if (jl_is_concrete_immutable (jt)) {
656656 if (jl_datatype_nbits (jt) == 0 )
@@ -760,7 +760,7 @@ static Type *_julia_struct_to_llvm(jl_codegen_params_t *ctx, LLVMContext &ctxt,
760760 // use this where C-compatible (unboxed) structs are desired
761761 // use julia_type_to_llvm directly when you want to preserve Julia's type semantics
762762 if (isboxed) *isboxed = false ;
763- if (jt == (jl_value_t *)jl_bottom_type)
763+ if (jt == (jl_value_t *)jl_bottom_type || jt == ( jl_value_t *)jl_typeofbottom_type || jt == ( jl_value_t *)jl_typeofbottom_type-> super )
764764 return getVoidTy (ctxt);
765765 if (jl_is_primitivetype (jt))
766766 return bitstype_to_llvm (jt, ctxt, llvmcall);
@@ -948,6 +948,9 @@ static bool for_each_uniontype_small(
948948 allunbox &= for_each_uniontype_small (f, ((jl_uniontype_t *)ty)->b , counter);
949949 return allunbox;
950950 }
951+ else if (ty == (jl_value_t *)jl_typeofbottom_type->super ) {
952+ f (++counter, jl_typeofbottom_type); // treat Tuple{union{}} as identical to typeof(Union{})
953+ }
951954 else if (jl_is_pointerfree (ty)) {
952955 f (++counter, (jl_datatype_t *)ty);
953956 return true ;
@@ -1691,6 +1694,8 @@ static std::pair<Value*, bool> emit_isa(jl_codectx_t &ctx, const jl_cgval_t &x,
16911694 if (intersected_type == (jl_value_t *)jl_bottom_type)
16921695 known_isa = false ;
16931696 }
1697+ if (intersected_type == (jl_value_t *)jl_typeofbottom_type->super )
1698+ intersected_type = (jl_value_t *)jl_typeofbottom_type; // swap abstract Type{Union{}} for concrete typeof(Union{})
16941699 if (known_isa) {
16951700 if (!*known_isa && !msg.isTriviallyEmpty ()) {
16961701 emit_type_error (ctx, x, literal_pointer_val (ctx, type), msg);
0 commit comments