1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 21:40:33 +02:00

Allow redefinitions in compiled code as in `(define round round)'.

* module/ice-9/psyntax-pp.scm: Regenerate.

* module/ice-9/psyntax.scm (chi-top)[define-form]: If a same-named
  imported variable exists, take its value instead of `#f'.

* test-suite/tests/compiler.test ("psyntax")["redefinition"]: New tests.
This commit is contained in:
Ludovic Courtès 2009-08-13 15:39:12 +02:00
parent 98850fd727
commit b9434165b6
3 changed files with 5987 additions and 5105 deletions

File diff suppressed because it is too large Load diff

View file

@ -1198,7 +1198,13 @@
;; affect compile-time environment (once we have booted)
(if (and (not (module-local-variable (current-module) n))
(current-module))
(module-define! (current-module) n #f))
(let ((old (module-variable (current-module) n)))
;; use value of the same-named imported variable, if
;; any
(module-define! (current-module) n
(if (variable? old)
(variable-ref old)
#f))))
(eval-if-c&e m
(build-global-definition s n (chi e r w mod))
mod))

View file

@ -25,3 +25,13 @@
(pass-if "compile to value"
(equal? (compile 1) 1)))
(with-test-prefix "psyntax"
(pass-if "redefinition"
;; In this case the locally-bound `round' must have the same value as the
;; imported `round'. See the same test in `syntax.test' for details.
(let ((o1 (compile '(define round round)))
(o2 (compile '(eq? round (@@ (guile) round)))))
o2)))