From 83d3cf793a4efefe601db426d75ccd2499dc8a88 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Fri, 9 Jun 2017 09:28:07 +0200 Subject: [PATCH] Fix inInference state corruption. This led to non-idempotent irgen. (cherry picked from commit f91d54fd92ae4093780f319d3adbb8a436ed0a2e, ref #22313) --- src/gf.c | 2 +- test/inference.jl | 7 +++++++ test/staged.jl | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gf.c b/src/gf.c index 822417e2e0897..cdeaae00a7e52 100644 --- a/src/gf.c +++ b/src/gf.c @@ -261,7 +261,7 @@ jl_code_info_t *jl_type_infer(jl_method_instance_t **pli, size_t world, int forc li->inInference = 1; jl_svec_t *linfo_src_rettype = (jl_svec_t*)jl_apply_with_saved_exception_state(fargs, 3, 0); ptls->world_age = last_age; - assert((li->def || li->inInference == 0) && "inference failed on a toplevel expr"); + li->inInference = 0; jl_code_info_t *src = NULL; if (jl_is_svec(linfo_src_rettype) && jl_svec_len(linfo_src_rettype) == 3 && diff --git a/test/inference.jl b/test/inference.jl index d6111ac96dad9..5f8f228b2a47f 100644 --- a/test/inference.jl +++ b/test/inference.jl @@ -952,3 +952,10 @@ g23024(TT::Tuple{DataType}) = f23024(TT[1], v23024) @test Base.return_types(f23024, (DataType, Any)) == Any[Int] @test Base.return_types(g23024, (Tuple{DataType},)) == Any[Int] @test g23024((UInt8,)) === 2 + +# issue #22290 +f22290() = return nothing +for i in 1:3 + ir = sprint(io->code_llvm(io, f22290, Tuple{})) + @test contains(ir, "julia_f22290") +end diff --git a/test/staged.jl b/test/staged.jl index ba62fc2d91816..e81f4b42a6cb4 100644 --- a/test/staged.jl +++ b/test/staged.jl @@ -174,7 +174,7 @@ let gf_err, tsk = @async nothing # create a Task for yield to try to run end @test_throws ErrorException gf_err() @test_throws ErrorException gf_err() - @test gf_err_ref[] == 3 + @test gf_err_ref[] == 4 end gf_err_ref[] = 0