fix compiler bug with unsafe-c[ad]r and constant folding (PR 10850)

svn: r18742
This commit is contained in:
Matthew Flatt 2010-04-07 02:25:27 +00:00
parent 63b819ce74
commit 2c36427b20
2 changed files with 12 additions and 0 deletions

View File

@ -311,4 +311,14 @@
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check that compiling a misapplication of `unsafe-car' and `unsafe-cdr'
;; (which are folding operations in the compiler ) doesn't crash:
(let ([f (lambda (x) (if x x (unsafe-car 3)))]
[g (lambda (x) (if x x (unsafe-cdr 4)))])
(test 5 f 5)
(test 5 g 5))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs)

View File

@ -3196,11 +3196,13 @@ void scheme_init_ephemerons(void)
static Scheme_Object *unsafe_car (int argc, Scheme_Object *argv[])
{
if (scheme_current_thread->constant_folding) return scheme_checked_car(argc, argv);
return SCHEME_CAR(argv[0]);
}
static Scheme_Object *unsafe_cdr (int argc, Scheme_Object *argv[])
{
if (scheme_current_thread->constant_folding) return scheme_checked_cdr(argc, argv);
return SCHEME_CDR(argv[0]);
}