mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
match undefined hygienically wrapper forward refs on define (fixes issue #399)
This commit is contained in:
parent
c03ae08bbd
commit
ae1a2aa6be
2 changed files with 19 additions and 0 deletions
9
eval.c
9
eval.c
|
@ -150,6 +150,15 @@ sexp sexp_env_cell_define (sexp ctx, sexp env, sexp key,
|
|||
if (sexp_car(ls) == key) {
|
||||
sexp_cdr(ls) = value;
|
||||
return ls;
|
||||
} else if (sexp_cdr(ls) == SEXP_UNDEF &&
|
||||
sexp_synclop(sexp_car(ls)) &&
|
||||
sexp_synclo_env(sexp_car(ls)) == env &&
|
||||
sexp_synclo_expr(sexp_car(ls)) == key) {
|
||||
/* handle an undefined renamed reference that would have */
|
||||
/* resolved to this binding, renamed to what we define here */
|
||||
sexp_car(ls) = key;
|
||||
sexp_cdr(ls) = value;
|
||||
return ls;
|
||||
}
|
||||
sexp_gc_preserve2(ctx, cell, ls);
|
||||
sexp_env_push(ctx, env, cell, key, value);
|
||||
|
|
|
@ -540,6 +540,16 @@
|
|||
'#(b)))))
|
||||
(test '#(b) (vector-lit)))
|
||||
|
||||
(let ()
|
||||
;; forward hygienic refs
|
||||
(define-syntax foo399
|
||||
(syntax-rules () ((foo399) (bar399))))
|
||||
(define (quux399)
|
||||
(foo399))
|
||||
(define (bar399)
|
||||
42)
|
||||
(test 42 (quux399)))
|
||||
|
||||
(test-end)
|
||||
|
||||
(test-begin "5 Program structure")
|
||||
|
|
Loading…
Add table
Reference in a new issue