;;; -*- mode: scheme; coding: utf-8; -*-
- ;;;; Copyright (C) 2009, 2010, 2011
- ;;;; Free Software Foundation, Inc.
-;;;; Copyright (C) 2009, 2010, 2012 Free Software Foundation, Inc.
++;;;; Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
(eval body new-env)
(lp (cdr inits)
(cons (eval (car inits) env) new-env)))))
-
- (('lambda (body nreq . tail))
- (if (null? tail)
- (make-fixed-closure eval nreq body (capture-env env))
- (if (null? (cdr tail))
- (make-general-closure (capture-env env) body nreq (car tail)
- 0 #f '() #f)
- (apply make-general-closure (capture-env env) body nreq tail))))
+
+ (('lambda (body docstring nreq . tail))
+ (let ((proc
+ (if (null? tail)
+ (make-fixed-closure eval nreq body (capture-env env))
+ (if (null? (cdr tail))
+ (make-general-closure (capture-env env) body
+ nreq (car tail)
+ 0 #f '() #f)
+ (apply make-general-closure (capture-env env)
+ body nreq tail)))))
+ (when docstring
+ (set-procedure-property! proc 'documentation docstring))
+ proc))
- (('begin (first . rest))
- (let lp ((first first) (rest rest))
- (if (null? rest)
- (eval first env)
- (begin
- (eval first env)
- (lp (car rest) (cdr rest))))))
-
+ (('seq (head . tail))
+ (begin
+ (eval head env)
+ (eval tail env)))
+
(('lexical-set! (n . x))
(let ((val (eval x env)))
(list-set! env n val)))
(pass-if-cse
(begin (cons 1 2 3) 4)
- (begin
- (apply (primitive cons) (const 1) (const 2) (const 3))
+ (seq
+ (primcall cons (const 1) (const 2) (const 3))
- (const 4))))
+ (const 4)))
+
+ (pass-if "http://bugs.gnu.org/12883"
+ ;; In 2.0.6, compiling this code would trigger an out-of-bounds
+ ;; vlist access in CSE's traversal of its "database".
+ (glil-program?
+ (compile '(define (proc v)
+ (let ((failure (lambda () (bail-out 'match))))
+ (if (and (pair? v)
+ (null? (cdr v)))
+ (let ((w foo)
+ (x (cdr w)))
+ (if (and (pair? x) (null? w))
+ #t
+ (failure)))
+ (failure))))
+ #:from 'scheme
+ #:to 'glil))))