diff --git a/base/compiler/ssair/passes.jl b/base/compiler/ssair/passes.jl index 34c69dcc2dc2ef..efacbf4ca219b7 100644 --- a/base/compiler/ssair/passes.jl +++ b/base/compiler/ssair/passes.jl @@ -537,7 +537,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 @@ -557,7 +557,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 2540d3c870e73d..d13d73ec6f10c6 100644 --- a/test/compiler/inference.jl +++ b/test/compiler/inference.jl @@ -2990,3 +2990,7 @@ f28971() = (1, [2,3]...)::Tuple{Int,Int,Int} let f() = sin{Int}() @test Base.return_types(f, ()) == Any[Union{}] end + +# issue #40804 +@test Base.return_types(()) do; ===(); end == Any[Union{}] +@test Base.return_types(()) do; typeassert(); end == Any[Union{}]