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.
This commit is contained in:
Alex Shinn 2013-10-10 16:41:01 +09:00
parent 363d2bda24
commit 7a5f317811

9
eval.c
View file

@ -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)) else if (!cell1 && !cell2 && (id1 == id2))
return SEXP_TRUE; return SEXP_TRUE;
#if ! SEXP_USE_STRICT_TOPLEVEL_BINDINGS #if ! SEXP_USE_STRICT_TOPLEVEL_BINDINGS
else if (cell1 && !sexp_lambdap(sexp_cdr(cell1)) /* If the identifiers are the same and the cells are either unbound *
&& cell2 && !sexp_lambdap(sexp_cdr(cell2)) * or bound to top-level variables, consider them the same. Local *
&& (id1 == id2)) * (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; return SEXP_TRUE;
#endif #endif
return SEXP_FALSE; return SEXP_FALSE;