From 623f0f3b7d9cd0a9ed27ccf85ea3667f6559f5f6 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 28 Jan 2016 00:33:36 -0500 Subject: [PATCH] fix UndefVarError problem caused by 25c3659d6cec2ebf6e6c7d16b03adac76a47b42a --- src/gf.c | 4 +++- test/linalg/tridiag.jl | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gf.c b/src/gf.c index 3c6e05890c051..e8fe34d1d1988 100644 --- a/src/gf.c +++ b/src/gf.c @@ -443,11 +443,13 @@ void jl_type_infer(jl_lambda_info_t *li, jl_tupletype_t *argtypes, jl_lambda_inf #endif #ifdef ENABLE_INFERENCE jl_value_t *newast = jl_apply(jl_typeinf_func, fargs, 4); + jl_value_t *defast = def->ast; li->ast = jl_fieldref(newast, 0); jl_gc_wb(li, li->ast); li->rettype = jl_fieldref(newast, 1); jl_gc_wb(li, li->rettype); - li->inferred = 1; + // if type inference bails out it returns def->ast + li->inferred = li->ast != defast; #endif li->inInference = 0; } diff --git a/test/linalg/tridiag.jl b/test/linalg/tridiag.jl index 80790c02c8370..3dc67cb470a1e 100644 --- a/test/linalg/tridiag.jl +++ b/test/linalg/tridiag.jl @@ -105,6 +105,10 @@ for elty in (Float32, Float64, Complex64, Complex128, Int) @test eigvecs(Ts) == eigvecs(Fs) #call to LAPACK.stein here Test.test_approx_eq_modphase(eigvecs(Ts,eigvals(Ts)),eigvecs(Fs)) + elseif elty != Int + # check that undef is determined accurately even if type inference + # bails out due to the number of try/catch blocks in this code. + @test_throws UndefVarError Fs end # Test det(A::Matrix)