Skip to content

Commit 8f512f3

Browse files
authored
fix #35793, assertion failure with union of singletons (#35812)
1 parent b828bbc commit 8f512f3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/cgutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ static Type *_julia_struct_to_llvm(jl_codegen_params_t *ctx, jl_value_t *jt, jl_
702702
Type *AlignmentType = IntegerType::get(jl_LLVMContext, 8 * al);
703703
unsigned NumATy = fsz / al;
704704
unsigned remainder = fsz % al;
705-
assert(NumATy > 0);
705+
assert(al == 1 || NumATy > 0);
706706
while (NumATy--)
707707
latypes.push_back(AlignmentType);
708708
while (remainder--)

test/core.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5961,6 +5961,16 @@ let a33709 = A33709(A33709(nothing))
59615961
@test isnothing(a33709.a.a)
59625962
end
59635963

5964+
# issue #35793
5965+
struct A35793
5966+
x::Union{Nothing, Missing}
5967+
end
5968+
let x = A35793(nothing), y = A35793(missing)
5969+
@test x isa A35793
5970+
@test x.x === nothing
5971+
@test y.x === missing
5972+
end
5973+
59645974
# issue 31583
59655975
a31583 = "a"
59665976
f31583() = a31583 === "a"

0 commit comments

Comments
 (0)