From 047f35432bbeddc4077541dc8112c157316d16be Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 19 Jun 2016 14:24:42 +0900 Subject: [PATCH] detecting variable uses in the wrong phase (issue #259) --- vm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vm.c b/vm.c index 4fe22d96..6acdf3ee 100644 --- a/vm.c +++ b/vm.c @@ -259,8 +259,13 @@ static void generate_ref (sexp ctx, sexp ref, int unboxp) { sexp_emit_push(ctx, sexp_ref_cell(ref)); } else { lam = sexp_context_lambda(ctx); - generate_non_global_ref(ctx, sexp_ref_name(ref), sexp_ref_cell(ref), - lam, sexp_lambda_fv(lam), unboxp); + if (!lam || !sexp_lambdap(lam)) { + sexp_warn(ctx, "variable out of phase: ", sexp_ref_name(ref)); + sexp_emit_push(ctx, SEXP_VOID); + } else { + generate_non_global_ref(ctx, sexp_ref_name(ref), sexp_ref_cell(ref), + lam, sexp_lambda_fv(lam), unboxp); + } } }