From 7a5f31781139c1249aa8b231fcce84895aab93af Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Thu, 10 Oct 2013 16:41:01 +0900 Subject: [PATCH] Fixing bug in the non-strict top-level identifier matching logic. Matching worked when both bindings were missing, and when both bindings were present at the top-level but different. The case when only one top-level binding was present wasn't handled correctly. Local lexical matching remains unchanged. Fixes issue #198. --- eval.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/eval.c b/eval.c index 72b81a79..462533f7 100644 --- a/eval.c +++ b/eval.c @@ -592,9 +592,12 @@ sexp sexp_identifier_eq_op (sexp ctx, sexp self, sexp_sint_t n, sexp e1, sexp id else if (!cell1 && !cell2 && (id1 == id2)) return SEXP_TRUE; #if ! SEXP_USE_STRICT_TOPLEVEL_BINDINGS - else if (cell1 && !sexp_lambdap(sexp_cdr(cell1)) - && cell2 && !sexp_lambdap(sexp_cdr(cell2)) - && (id1 == id2)) + /* If the identifiers are the same and the cells are either unbound * + * or bound to top-level variables, consider them the same. Local * + * (non-toplevel) bindings must still match exactly. */ + else if ((id1 == id2) + && (!cell1 || !sexp_lambdap(sexp_cdr(cell1))) + && (!cell2 || !sexp_lambdap(sexp_cdr(cell2)))) return SEXP_TRUE; #endif return SEXP_FALSE;