From 8f512f3f6d5d69403be4b8179bd80ba64229e761 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sat, 9 May 2020 14:32:33 -0400 Subject: [PATCH] fix #35793, assertion failure with union of singletons (#35812) --- src/cgutils.cpp | 2 +- test/core.jl | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cgutils.cpp b/src/cgutils.cpp index 87c3b5ee75f34..d23bf9c20e7e6 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -702,7 +702,7 @@ static Type *_julia_struct_to_llvm(jl_codegen_params_t *ctx, jl_value_t *jt, jl_ Type *AlignmentType = IntegerType::get(jl_LLVMContext, 8 * al); unsigned NumATy = fsz / al; unsigned remainder = fsz % al; - assert(NumATy > 0); + assert(al == 1 || NumATy > 0); while (NumATy--) latypes.push_back(AlignmentType); while (remainder--) diff --git a/test/core.jl b/test/core.jl index da814873820fd..98344bfb44506 100644 --- a/test/core.jl +++ b/test/core.jl @@ -5961,6 +5961,16 @@ let a33709 = A33709(A33709(nothing)) @test isnothing(a33709.a.a) end +# issue #35793 +struct A35793 + x::Union{Nothing, Missing} +end +let x = A35793(nothing), y = A35793(missing) + @test x isa A35793 + @test x.x === nothing + @test y.x === missing +end + # issue 31583 a31583 = "a" f31583() = a31583 === "a"