From 0e5f09f1a634c8953518e57a76b73caba6953e7b Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 26 Feb 2015 14:29:14 -0500 Subject: [PATCH] only limit argument lists that are growing by recursion --- base/inference.jl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/base/inference.jl b/base/inference.jl index 1946b746e0a3e..8b131d1f7e012 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -742,8 +742,17 @@ function abstract_call_gf(f, fargs, argtypes, e) # limit argument type tuple based on size of definition signature. # for example, given function f(T, Any...), limit to 3 arguments # instead of the default (MAX_TUPLETYPE_LEN) + sp = inference_stack + limit = false + # look at the stack to detect recursive calls with growing argument lists + while sp !== EmptyCallStack() + if linfo.ast === sp.ast && length(argtypes) > length(sp.types) + limit = true; break + end + sp = sp.prev + end ls = length(sig) - if ls > lsig+1 && !(isdefined(Main.Base,:promote_typeof) && f === Main.Base.promote_typeof) + if limit && ls > lsig+1 && !(isdefined(Main.Base,:promote_typeof) && f === Main.Base.promote_typeof) fst = sig[lsig+1] allsame = true # allow specializing on longer arglists if all the trailing