diff --git a/base/compiler/ssair/passes.jl b/base/compiler/ssair/passes.jl index 114b8c6033615..40d0a14068a29 100644 --- a/base/compiler/ssair/passes.jl +++ b/base/compiler/ssair/passes.jl @@ -571,7 +571,7 @@ function getfield_elim_pass!(ir::IRCode) elseif is_known_call(stmt, isa, compact) # TODO continue - elseif is_known_call(stmt, typeassert, compact) + elseif is_known_call(stmt, typeassert, compact) && length(stmt.args) == 3 # Canonicalize # X = typeassert(Y, T)::S # into @@ -592,7 +592,7 @@ function getfield_elim_pass!(ir::IRCode) compact.result[idx][:line]), true) compact.ssa_rename[compact.idx-1] = pi continue - elseif is_known_call(stmt, (===), compact) + elseif is_known_call(stmt, (===), compact) && length(stmt.args) == 3 c1 = compact_exprtype(compact, stmt.args[2]) c2 = compact_exprtype(compact, stmt.args[3]) if !(isa(c1, Const) || isa(c2, Const)) diff --git a/test/compiler/inference.jl b/test/compiler/inference.jl index 5cbd39d8468a6..2c49042892629 100644 --- a/test/compiler/inference.jl +++ b/test/compiler/inference.jl @@ -3313,3 +3313,7 @@ end |> first === Tuple{Int, String} # issue #40742 @test Base.return_types(string, (Vector{Tuple{:x}},)) == Any[String] + +# issue #40804 +@test Base.return_types(()) do; ===(); end == Any[Union{}] +@test Base.return_types(()) do; typeassert(); end == Any[Union{}]