2001-03-02 01:38:01 +00:00
|
|
|
;;;; syntax.test --- test suite for Guile's syntactic forms -*- scheme -*-
|
|
|
|
|
;;;;
|
2012-01-05 22:38:06 +01:00
|
|
|
;;;; Copyright (C) 2001, 2003, 2004, 2005, 2006, 2009, 2010,
|
2014-01-15 03:08:32 -05:00
|
|
|
;;;; 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
|
2012-01-05 22:38:06 +01:00
|
|
|
;;;;
|
2009-06-17 00:22:09 +01:00
|
|
|
;;;; This library is free software; you can redistribute it and/or
|
|
|
|
|
;;;; modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
;;;; License as published by the Free Software Foundation; either
|
|
|
|
|
;;;; version 3 of the License, or (at your option) any later version.
|
2001-03-02 01:38:01 +00:00
|
|
|
;;;;
|
2009-06-17 00:22:09 +01:00
|
|
|
;;;; This library is distributed in the hope that it will be useful,
|
2001-03-02 01:38:01 +00:00
|
|
|
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2009-06-17 00:22:09 +01:00
|
|
|
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
;;;; Lesser General Public License for more details.
|
2001-03-02 01:38:01 +00:00
|
|
|
;;;;
|
2009-06-17 00:22:09 +01:00
|
|
|
;;;; You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
;;;; License along with this library; if not, write to the Free Software
|
|
|
|
|
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2003-09-22 19:00:41 +00:00
|
|
|
(define-module (test-suite test-syntax)
|
2010-11-18 11:04:15 +01:00
|
|
|
#:use-module (ice-9 regex)
|
2013-12-18 18:49:37 -05:00
|
|
|
#:use-module (ice-9 local-eval)
|
2017-04-21 11:04:08 +02:00
|
|
|
#:use-module ((system syntax) #:select (syntax?))
|
2010-11-18 11:04:15 +01:00
|
|
|
#:use-module (test-suite lib))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
|
2009-05-21 22:11:48 +02:00
|
|
|
(define exception:generic-syncase-error
|
2010-11-18 11:04:15 +01:00
|
|
|
"source expression failed to match")
|
2009-05-21 22:11:48 +02:00
|
|
|
(define exception:unexpected-syntax
|
2010-11-18 11:04:15 +01:00
|
|
|
"unexpected syntax")
|
2009-05-21 22:11:48 +02:00
|
|
|
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
(define exception:bad-expression
|
2010-11-18 11:04:15 +01:00
|
|
|
"Bad expression")
|
2003-10-11 16:03:29 +00:00
|
|
|
|
2003-10-18 14:49:55 +00:00
|
|
|
(define exception:missing/extra-expr
|
2010-11-18 11:04:15 +01:00
|
|
|
"Missing or extra expression")
|
2003-10-11 16:03:29 +00:00
|
|
|
(define exception:missing-expr
|
2010-11-18 11:04:15 +01:00
|
|
|
"Missing expression")
|
2019-08-25 16:44:07 +02:00
|
|
|
(define exception:empty-body
|
|
|
|
|
"empty body")
|
|
|
|
|
(define exception:body-should-end-with-expr
|
|
|
|
|
"body should end with an expression")
|
2003-10-11 16:03:29 +00:00
|
|
|
(define exception:extra-expr
|
2010-11-18 11:04:15 +01:00
|
|
|
"Extra expression")
|
2003-11-01 07:26:44 +00:00
|
|
|
(define exception:illegal-empty-combination
|
2010-11-18 11:04:15 +01:00
|
|
|
"Illegal empty combination")
|
2003-10-11 16:03:29 +00:00
|
|
|
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
(define exception:bad-lambda
|
2010-11-18 11:04:15 +01:00
|
|
|
"bad lambda")
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
(define exception:bad-let
|
2010-11-18 11:04:15 +01:00
|
|
|
"bad let$")
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
(define exception:bad-letrec
|
2010-11-18 11:04:15 +01:00
|
|
|
"bad letrec$")
|
2010-06-17 14:39:32 +02:00
|
|
|
(define exception:bad-letrec*
|
2010-11-18 11:04:15 +01:00
|
|
|
"bad letrec\\*$")
|
2009-05-22 12:22:39 +02:00
|
|
|
(define exception:bad-set!
|
2010-11-18 11:04:15 +01:00
|
|
|
"bad set!")
|
2009-05-22 12:22:39 +02:00
|
|
|
(define exception:bad-quote
|
2010-11-18 11:04:15 +01:00
|
|
|
'(quote . "bad syntax"))
|
2001-03-02 01:38:01 +00:00
|
|
|
(define exception:bad-bindings
|
2010-11-18 11:04:15 +01:00
|
|
|
"Bad bindings")
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
(define exception:bad-binding
|
2010-11-18 11:04:15 +01:00
|
|
|
"Bad binding")
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
(define exception:duplicate-binding
|
2010-11-18 11:04:15 +01:00
|
|
|
"duplicate bound variable")
|
2001-03-02 01:38:01 +00:00
|
|
|
(define exception:bad-body
|
2010-11-18 11:04:15 +01:00
|
|
|
"^bad body")
|
2001-03-02 01:38:01 +00:00
|
|
|
(define exception:bad-formals
|
2010-11-18 11:04:15 +01:00
|
|
|
"invalid argument list")
|
2003-10-12 20:47:32 +00:00
|
|
|
(define exception:bad-formal
|
2010-11-18 11:04:15 +01:00
|
|
|
"Bad formal")
|
2009-10-25 12:36:44 +01:00
|
|
|
(define exception:duplicate-formals
|
2010-11-18 11:04:15 +01:00
|
|
|
"duplicate identifier in argument list")
|
2003-10-11 16:03:29 +00:00
|
|
|
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
(define exception:missing-clauses
|
2010-11-18 11:04:15 +01:00
|
|
|
"Missing clauses")
|
2003-10-11 10:40:19 +00:00
|
|
|
(define exception:misplaced-else-clause
|
2010-11-18 11:04:15 +01:00
|
|
|
"Misplaced else clause")
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
(define exception:bad-case-clause
|
2010-11-18 11:04:15 +01:00
|
|
|
"Bad case clause")
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
(define exception:bad-case-labels
|
2010-11-18 11:04:15 +01:00
|
|
|
"Bad case labels")
|
2003-10-11 10:40:19 +00:00
|
|
|
(define exception:bad-cond-clause
|
2010-11-18 11:04:15 +01:00
|
|
|
"Bad cond clause")
|
2003-10-11 16:03:29 +00:00
|
|
|
|
2010-06-11 16:57:50 +02:00
|
|
|
(define exception:too-many-args
|
2010-11-18 11:04:15 +01:00
|
|
|
"too many arguments")
|
2014-02-07 15:15:08 +01:00
|
|
|
(define exception:wrong-number-of-values
|
|
|
|
|
'(wrong-number-of-args . "number of (values)|(arguments)"))
|
2012-01-05 23:49:01 +01:00
|
|
|
(define exception:zero-expression-sequence
|
|
|
|
|
"sequence of zero expressions")
|
2010-11-18 11:04:15 +01:00
|
|
|
|
2014-12-04 15:07:01 +01:00
|
|
|
(define exception:variable-ref
|
2014-12-10 16:25:19 +01:00
|
|
|
'(misc-error . "Unbound variable"))
|
2010-11-18 11:04:15 +01:00
|
|
|
|
|
|
|
|
;; (put 'pass-if-syntax-error 'scheme-indent-function 1)
|
|
|
|
|
(define-syntax pass-if-syntax-error
|
|
|
|
|
(syntax-rules ()
|
|
|
|
|
((_ name pat exp)
|
|
|
|
|
(pass-if name
|
|
|
|
|
(catch 'syntax-error
|
2012-01-05 22:38:06 +01:00
|
|
|
(lambda () exp (error "expected syntax-error exception"))
|
2010-11-18 11:04:15 +01:00
|
|
|
(lambda (k who what where form . maybe-subform)
|
|
|
|
|
(if (if (pair? pat)
|
|
|
|
|
(and (eq? who (car pat))
|
|
|
|
|
(string-match (cdr pat) what))
|
|
|
|
|
(string-match pat what))
|
|
|
|
|
#t
|
|
|
|
|
(error "unexpected syntax-error exception" what pat))))))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "expressions"
|
|
|
|
|
|
2003-10-07 22:00:05 +00:00
|
|
|
(with-test-prefix "Bad argument list"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "improper argument list of length 1"
|
2009-05-21 22:11:48 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ((foo (lambda (x y) #t)))
|
|
|
|
|
(foo . 1))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "improper argument list of length 2"
|
2009-05-21 22:11:48 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ((foo (lambda (x y) #t)))
|
|
|
|
|
(foo 1 . 2))
|
|
|
|
|
(interaction-environment))))
|
|
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
(with-test-prefix "missing or extra expression"
|
|
|
|
|
|
|
|
|
|
;; R5RS says:
|
|
|
|
|
;; *Note:* In many dialects of Lisp, the empty combination, (),
|
|
|
|
|
;; is a legitimate expression. In Scheme, combinations must
|
|
|
|
|
;; have at least one subexpression, so () is not a syntactically
|
|
|
|
|
;; valid expression.
|
2001-03-03 17:29:09 +00:00
|
|
|
|
|
|
|
|
;; Fixed on 2001-3-3
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "empty parentheses \"()\""
|
2009-05-21 22:11:48 +02:00
|
|
|
exception:unexpected-syntax
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '()
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-11-17 11:44:06 +00:00
|
|
|
(with-test-prefix "quote"
|
|
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "quasiquote"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "unquote"
|
|
|
|
|
|
|
|
|
|
(pass-if "repeated execution"
|
|
|
|
|
(let ((foo (let ((i 0)) (lambda () (set! i (+ i 1)) `(,i)))))
|
|
|
|
|
(and (equal? (foo) '(1)) (equal? (foo) '(2))))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "unquote-splicing"
|
|
|
|
|
|
2011-02-08 22:43:43 +01:00
|
|
|
(pass-if "extra arguments"
|
|
|
|
|
(equal? (eval '(quasiquote ((unquote-splicing (list 1 2) (list 3 4))))
|
|
|
|
|
(interaction-environment))
|
|
|
|
|
'(1 2 3 4)))))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "begin"
|
|
|
|
|
|
2012-01-05 23:49:01 +01:00
|
|
|
(pass-if "valid (begin)"
|
2009-05-18 23:45:35 +02:00
|
|
|
(eval '(begin (begin) #t) (interaction-environment)))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
2011-12-21 20:10:42 -05:00
|
|
|
(if (not (include-deprecated-features))
|
2012-01-05 23:49:01 +01:00
|
|
|
(pass-if-syntax-error "invalid (begin)"
|
|
|
|
|
exception:zero-expression-sequence
|
2011-12-21 20:10:42 -05:00
|
|
|
(eval '(begin (if #t (begin)) #t) (interaction-environment)))))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
2009-05-21 22:43:07 +02:00
|
|
|
(define-syntax matches?
|
2010-06-21 21:06:29 +02:00
|
|
|
(syntax-rules (<>)
|
2009-05-21 22:43:07 +02:00
|
|
|
((_ (op arg ...) pat) (let ((x (op arg ...)))
|
|
|
|
|
(matches? x pat)))
|
|
|
|
|
((_ x ()) (null? x))
|
|
|
|
|
((_ x (a . b)) (and (pair? x)
|
|
|
|
|
(matches? (car x) a)
|
|
|
|
|
(matches? (cdr x) b)))
|
2010-06-21 21:06:29 +02:00
|
|
|
((_ x <>) #t)
|
2009-05-21 22:43:07 +02:00
|
|
|
((_ x pat) (equal? x 'pat))))
|
|
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
(with-test-prefix "lambda"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "bad formals"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(lambda)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-lambda
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda)
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 23:59:27 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(lambda . \"foo\")"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-lambda
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda . "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 23:59:27 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(lambda \"foo\")"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-lambda
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 23:59:27 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(lambda \"foo\" #f)"
|
2001-10-13 23:59:27 +00:00
|
|
|
exception:bad-formals
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(lambda "foo" #f)
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 23:59:27 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(lambda (x 1) 2)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-formals
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda (x 1) 2)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(lambda (1 x) 2)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-formals
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda (1 x) 2)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(lambda (x \"a\") 2)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-formals
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda (x "a") 2)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(lambda (\"a\" x) 2)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-formals
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda ("a" x) 2)
|
|
|
|
|
(interaction-environment))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-03-03 17:29:09 +00:00
|
|
|
(with-test-prefix "duplicate formals"
|
|
|
|
|
|
|
|
|
|
;; Fixed on 2001-3-3
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(lambda (x x) 1)"
|
2009-10-25 12:36:44 +01:00
|
|
|
exception:duplicate-formals
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda (x x) 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-03-03 17:29:09 +00:00
|
|
|
;; Fixed on 2001-3-3
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(lambda (x x x) 1)"
|
2009-10-25 12:36:44 +01:00
|
|
|
exception:duplicate-formals
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda (x x x) 1)
|
|
|
|
|
(interaction-environment))))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "bad body"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(lambda ())"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-lambda
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda ())
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "let"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "bindings"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "late binding"
|
|
|
|
|
exception:unbound-var
|
|
|
|
|
(let ((x 1) (y x)) y)))
|
|
|
|
|
|
2001-11-17 11:44:06 +00:00
|
|
|
(with-test-prefix "bad bindings"
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-let
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let 1)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-let
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let (x))"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-let
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let (x))
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let ((x)))"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-let
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ((x)))
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let (x) 1)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-let
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let (x) 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let ((x)) 3)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-let
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ((x)) 3)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let ((x 1) y) x)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-let
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ((x 1) y) x)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let ((1 2)) 3)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-let
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(let ((1 2)) 3)
|
|
|
|
|
(interaction-environment))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-03-03 23:54:42 +00:00
|
|
|
(with-test-prefix "duplicate bindings"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let ((x 1) (x 2)) x)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:duplicate-binding
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ((x 1) (x 2)) x)
|
|
|
|
|
(interaction-environment))))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "bad body"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let ())"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-let
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ())
|
|
|
|
|
(interaction-environment)))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let ((x 1)))"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-let
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ((x 1)))
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "named let"
|
|
|
|
|
|
2001-11-17 11:44:06 +00:00
|
|
|
(with-test-prefix "initializers"
|
|
|
|
|
|
|
|
|
|
(pass-if "evaluated in outer environment"
|
|
|
|
|
(let ((f -))
|
|
|
|
|
(eqv? (let f ((n (f 1))) n) -1))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "bad bindings"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let x (y))"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-let
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let x (y))
|
|
|
|
|
(interaction-environment))))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
(with-test-prefix "bad body"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let x ())"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-let
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let x ())
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let x ((y 1)))"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-let
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let x ((y 1)))
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "let*"
|
|
|
|
|
|
2001-03-11 23:31:58 +00:00
|
|
|
(with-test-prefix "bindings"
|
|
|
|
|
|
|
|
|
|
(pass-if "(let* ((x 1) (x 2)) ...)"
|
|
|
|
|
(let* ((x 1) (x 2))
|
|
|
|
|
(= x 2)))
|
|
|
|
|
|
|
|
|
|
(pass-if "(let* ((x 1) (x x)) ...)"
|
|
|
|
|
(let* ((x 1) (x x))
|
2004-05-31 15:31:04 +00:00
|
|
|
(= x 1)))
|
|
|
|
|
|
|
|
|
|
(pass-if "(let ((x 1) (y 2)) (let* () ...))"
|
|
|
|
|
(let ((x 1) (y 2))
|
|
|
|
|
(let* ()
|
|
|
|
|
(and (= x 1) (= y 2))))))
|
2001-03-11 23:31:58 +00:00
|
|
|
|
2001-11-17 11:44:06 +00:00
|
|
|
(with-test-prefix "bad bindings"
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let*)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let*)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let* 1)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let* (x))"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* (x))
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let* (x) 1)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* (x) 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let* ((x)) 3)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* ((x)) 3)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let* ((x 1) y) x)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* ((x 1) y) x)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let* x ())"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(let* x ())
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let* x (y))"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(let* x (y))
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let* ((1 2)) 3)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(let* ((1 2)) 3)
|
|
|
|
|
(interaction-environment))))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "bad body"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let* ())"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* ())
|
|
|
|
|
(interaction-environment)))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(let* ((x 1)))"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* ((x 1)))
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "letrec"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "bindings"
|
|
|
|
|
|
2014-12-04 15:07:01 +01:00
|
|
|
(pass-if-exception "initial bindings are undefined"
|
|
|
|
|
exception:variable-ref
|
|
|
|
|
(eval '(let ((x 1))
|
|
|
|
|
(letrec ((x 1) (y x)) y))
|
|
|
|
|
(interaction-environment))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-11-17 11:44:06 +00:00
|
|
|
(with-test-prefix "bad bindings"
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-letrec
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec 1)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-letrec
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec (x))"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-letrec
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec (x))
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec (x) 1)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-letrec
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec (x) 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec ((x)) 3)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-letrec
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec ((x)) 3)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec ((x 1) y) x)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-letrec
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec ((x 1) y) x)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec x ())"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-letrec
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(letrec x ())
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec x (y))"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-letrec
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(letrec x (y))
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec ((1 2)) 3)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-letrec
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(letrec ((1 2)) 3)
|
|
|
|
|
(interaction-environment))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-03-03 23:54:42 +00:00
|
|
|
(with-test-prefix "duplicate bindings"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec ((x 1) (x 2)) x)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:duplicate-binding
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec ((x 1) (x 2)) x)
|
|
|
|
|
(interaction-environment))))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "bad body"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec ())"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-letrec
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec ())
|
|
|
|
|
(interaction-environment)))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec ((x 1)))"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:bad-letrec
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec ((x 1)))
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-06-17 14:39:32 +02:00
|
|
|
(with-test-prefix "letrec*"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "bindings"
|
|
|
|
|
|
2014-12-04 15:07:01 +01:00
|
|
|
(pass-if-exception "initial bindings are undefined"
|
|
|
|
|
exception:variable-ref
|
|
|
|
|
(eval '(letrec* ((x y) (y 1)) y)
|
|
|
|
|
(interaction-environment))))
|
2010-06-17 14:39:32 +02:00
|
|
|
|
|
|
|
|
(with-test-prefix "bad bindings"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec*)"
|
2010-06-17 14:39:32 +02:00
|
|
|
exception:bad-letrec*
|
|
|
|
|
(eval '(letrec*)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec* 1)"
|
2010-06-17 14:39:32 +02:00
|
|
|
exception:bad-letrec*
|
|
|
|
|
(eval '(letrec* 1)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec* (x))"
|
2010-06-17 14:39:32 +02:00
|
|
|
exception:bad-letrec*
|
|
|
|
|
(eval '(letrec* (x))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec* (x) 1)"
|
2010-06-17 14:39:32 +02:00
|
|
|
exception:bad-letrec*
|
|
|
|
|
(eval '(letrec* (x) 1)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec* ((x)) 3)"
|
2010-06-17 14:39:32 +02:00
|
|
|
exception:bad-letrec*
|
|
|
|
|
(eval '(letrec* ((x)) 3)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec* ((x 1) y) x)"
|
2010-06-17 14:39:32 +02:00
|
|
|
exception:bad-letrec*
|
|
|
|
|
(eval '(letrec* ((x 1) y) x)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec* x ())"
|
2010-06-17 14:39:32 +02:00
|
|
|
exception:bad-letrec*
|
|
|
|
|
(eval '(letrec* x ())
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec* x (y))"
|
2010-06-17 14:39:32 +02:00
|
|
|
exception:bad-letrec*
|
|
|
|
|
(eval '(letrec* x (y))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec* ((1 2)) 3)"
|
2010-06-17 14:39:32 +02:00
|
|
|
exception:bad-letrec*
|
|
|
|
|
(eval '(letrec* ((1 2)) 3)
|
|
|
|
|
(interaction-environment))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "duplicate bindings"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec* ((x 1) (x 2)) x)"
|
2010-06-17 14:39:32 +02:00
|
|
|
exception:duplicate-binding
|
|
|
|
|
(eval '(letrec* ((x 1) (x 2)) x)
|
|
|
|
|
(interaction-environment))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "bad body"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec* ())"
|
2010-06-17 14:39:32 +02:00
|
|
|
exception:bad-letrec*
|
|
|
|
|
(eval '(letrec* ())
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(letrec* ((x 1)))"
|
2010-06-17 14:39:32 +02:00
|
|
|
exception:bad-letrec*
|
|
|
|
|
(eval '(letrec* ((x 1)))
|
|
|
|
|
(interaction-environment))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "referencing previous values"
|
2014-12-04 15:07:01 +01:00
|
|
|
(pass-if (equal? (letrec* ((a (cons 'foo 'bar))
|
|
|
|
|
(b a))
|
2010-06-17 14:39:32 +02:00
|
|
|
b)
|
|
|
|
|
'(foo . bar)))
|
|
|
|
|
(pass-if (equal? (let ()
|
|
|
|
|
(define a (cons 'foo 'bar))
|
|
|
|
|
(define b a)
|
|
|
|
|
b)
|
|
|
|
|
'(foo . bar)))))
|
|
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
(with-test-prefix "if"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "missing or extra expressions"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(if)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(if)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(if 1 2 3 4)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(if 1 2 3 4)
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "cond"
|
|
|
|
|
|
2004-05-31 15:31:04 +00:00
|
|
|
(with-test-prefix "cond is hygienic"
|
|
|
|
|
|
|
|
|
|
(pass-if "bound 'else is handled correctly"
|
|
|
|
|
(eq? (let ((else 'ok)) (cond (else))) 'ok))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "bound '=> is handled correctly"
|
|
|
|
|
|
|
|
|
|
(pass-if "#t => 'ok"
|
|
|
|
|
(let ((=> 'foo))
|
|
|
|
|
(eq? (cond (#t => 'ok)) 'ok)))
|
|
|
|
|
|
|
|
|
|
(pass-if "else =>"
|
|
|
|
|
(let ((=> 'foo))
|
|
|
|
|
(eq? (cond (else =>)) 'foo)))
|
|
|
|
|
|
|
|
|
|
(pass-if "else => identity"
|
|
|
|
|
(let ((=> 'foo))
|
|
|
|
|
(eq? (cond (else => identity)) identity)))))
|
|
|
|
|
|
2007-07-18 20:25:38 +00:00
|
|
|
(with-test-prefix "SRFI-61"
|
|
|
|
|
|
|
|
|
|
(pass-if "always available"
|
|
|
|
|
(cond-expand (srfi-61 #t) (else #f)))
|
|
|
|
|
|
|
|
|
|
(pass-if "single value consequent"
|
|
|
|
|
(eq? 'ok (cond (#t identity => (lambda (x) 'ok)) (else #f))))
|
|
|
|
|
|
|
|
|
|
(pass-if "single value alternate"
|
|
|
|
|
(eq? 'ok (cond (#t not => (lambda (x) #f)) (else 'ok))))
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "doesn't affect standard =>"
|
|
|
|
|
exception:wrong-num-args
|
|
|
|
|
(cond ((values 1 2) => (lambda (x y) #t))))
|
|
|
|
|
|
|
|
|
|
(pass-if "multiple values consequent"
|
|
|
|
|
(equal? '(2 1) (cond ((values 1 2)
|
|
|
|
|
(lambda (one two)
|
|
|
|
|
(and (= 1 one) (= 2 two))) =>
|
|
|
|
|
(lambda (one two) (list two one)))
|
|
|
|
|
(else #f))))
|
|
|
|
|
|
|
|
|
|
(pass-if "multiple values alternate"
|
|
|
|
|
(eq? 'ok (cond ((values 2 3 4)
|
|
|
|
|
(lambda args (equal? '(1 2 3) args)) =>
|
|
|
|
|
(lambda (x y z) #f))
|
|
|
|
|
(else 'ok))))
|
|
|
|
|
|
|
|
|
|
(pass-if "zero values"
|
|
|
|
|
(eq? 'ok (cond ((values) (lambda () #t) => (lambda () 'ok))
|
|
|
|
|
(else #f))))
|
|
|
|
|
|
|
|
|
|
(pass-if "bound => is handled correctly"
|
|
|
|
|
(let ((=> 'ok))
|
|
|
|
|
(eq? 'ok (cond (#t identity =>) (else #f)))))
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "missing recipient"
|
|
|
|
|
'(cond . "wrong number of receiver expressions")
|
2012-02-07 19:40:29 -05:00
|
|
|
(eval '(cond (#t identity =>))
|
|
|
|
|
(interaction-environment)))
|
2007-07-18 20:25:38 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "extra recipient"
|
|
|
|
|
'(cond . "wrong number of receiver expressions")
|
2012-02-07 19:40:29 -05:00
|
|
|
(eval '(cond (#t identity => identity identity))
|
|
|
|
|
(interaction-environment))))
|
2007-07-18 20:25:38 +00:00
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
(with-test-prefix "bad or missing clauses"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(cond)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(cond #t)"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(cond . "invalid clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond #t)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(cond 1)"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(cond . "invalid clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(cond 1 2)"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(cond . "invalid clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond 1 2)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(cond 1 2 3)"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(cond . "invalid clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond 1 2 3)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(cond 1 2 3 4)"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(cond . "invalid clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond 1 2 3 4)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(cond ())"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(cond . "invalid clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond ())
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(cond () 1)"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(cond . "invalid clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond () 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(cond (1) 1)"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(cond . "invalid clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond (1) 1)
|
2012-02-07 19:40:29 -05:00
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "(cond (else #f) (#t #t))"
|
|
|
|
|
'(cond . "else must be the last clause")
|
|
|
|
|
(eval '(cond (else #f) (#t #t))
|
2004-05-31 15:31:04 +00:00
|
|
|
(interaction-environment))))
|
2001-10-18 21:59:29 +00:00
|
|
|
|
2003-10-07 22:00:05 +00:00
|
|
|
(with-test-prefix "wrong number of arguments"
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2003-10-07 22:00:05 +00:00
|
|
|
(pass-if-exception "=> (lambda (x y) #t)"
|
|
|
|
|
exception:wrong-num-args
|
|
|
|
|
(cond (1 => (lambda (x y) #t))))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-10-13 17:02:01 +00:00
|
|
|
(with-test-prefix "case"
|
|
|
|
|
|
2003-10-11 01:52:25 +00:00
|
|
|
(pass-if "clause with empty labels list"
|
|
|
|
|
(case 1 (() #f) (else #t)))
|
|
|
|
|
|
2012-02-07 19:40:29 -05:00
|
|
|
(with-test-prefix "case handles '=> correctly"
|
|
|
|
|
|
|
|
|
|
(pass-if "(1 2 3) => list"
|
|
|
|
|
(equal? (case 1 ((1 2 3) => list))
|
|
|
|
|
'(1)))
|
|
|
|
|
|
|
|
|
|
(pass-if "else => list"
|
|
|
|
|
(equal? (case 6
|
|
|
|
|
((1 2 3) 'wrong)
|
|
|
|
|
(else => list))
|
|
|
|
|
'(6)))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "bound '=> is handled correctly"
|
|
|
|
|
|
|
|
|
|
(pass-if "(1) => 'ok"
|
|
|
|
|
(let ((=> 'foo))
|
|
|
|
|
(eq? (case 1 ((1) => 'ok)) 'ok)))
|
|
|
|
|
|
|
|
|
|
(pass-if "else =>"
|
|
|
|
|
(let ((=> 'foo))
|
|
|
|
|
(eq? (case 1 (else =>)) 'foo)))
|
|
|
|
|
|
|
|
|
|
(pass-if "else => list"
|
|
|
|
|
(let ((=> 'foo))
|
|
|
|
|
(eq? (case 1 (else => identity)) identity))))
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "missing recipient"
|
|
|
|
|
'(case . "wrong number of receiver expressions")
|
|
|
|
|
(eval '(case 1 ((1) =>))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "extra recipient"
|
|
|
|
|
'(case . "wrong number of receiver expressions")
|
|
|
|
|
(eval '(case 1 ((1) => identity identity))
|
|
|
|
|
(interaction-environment))))
|
|
|
|
|
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
(with-test-prefix "case is hygienic"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "bound 'else is handled correctly"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(case . "invalid clause")
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
(eval '(let ((else #f)) (case 1 (else #f)))
|
|
|
|
|
(interaction-environment))))
|
|
|
|
|
|
2001-10-13 17:02:01 +00:00
|
|
|
(with-test-prefix "bad or missing clauses"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(case)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case)
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(case . \"foo\")"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case . "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(case 1)"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1)
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(case 1 . \"foo\")"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 . "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(case 1 \"foo\")"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(case . "invalid clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(case 1 ())"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(case . "invalid clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 ())
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(case 1 (\"foo\"))"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(case . "invalid clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 ("foo"))
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(case 1 (\"foo\" \"bar\"))"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(case . "invalid clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 ("foo" "bar"))
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(case 1 ((2) \"bar\") . \"foo\")"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 ((2) "bar") . "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(case 1 ((2) \"bar\") (else))"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(case . "invalid clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 ((2) "bar") (else))
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(case 1 (else #f) . \"foo\")"
|
residualize names into procedures. re-implement srfi-61. module naming foo.
* module/ice-9/boot-9.scm (cond): Implement srfi-61; most of the code is
from the SRFI itself. Yuk.
(%print-module, make-modules-in, %app, (%app modules))
(module-name): Syncase needs to get at the names of modules, even at
anonymous modules. So lazily assign gensyms as module names. Name %app
as (%app), but since (%app modules) is at the top of the module
hierarchy, name it ().
* module/ice-9/psyntax.scm: When building tree-il, try to name lambdas in
definitions and in lets.
(let, letrec): Give more specific errors in a couple of cases.
* module/ice-9/psyntax-pp.scm: Regenerated.
* test-suite/tests/syntax.test: More work. Many exceptions have different
messages than they used to, many more generic; we can roll this back to
be faithful to the original strings, but it doesn't seem necessary to
me.
2009-05-22 12:08:50 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 (else #f) . "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(case 1 (else #f) ((1) #t))"
|
2012-02-07 19:40:29 -05:00
|
|
|
'(case . "else must be the last clause")
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 (else #f) ((1) #t))
|
|
|
|
|
(interaction-environment)))))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2003-11-08 08:11:14 +00:00
|
|
|
(with-test-prefix "top-level define"
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2007-05-26 14:30:50 +00:00
|
|
|
(pass-if "redefinition"
|
|
|
|
|
(let ((m (make-module)))
|
|
|
|
|
(beautify-user-module! m)
|
|
|
|
|
|
|
|
|
|
;; The previous value of `round' must still be visible at the time the
|
|
|
|
|
;; new `round' is defined. According to R5RS (Section 5.2.1), `define'
|
|
|
|
|
;; should behave like `set!' in this case (except that in the case of
|
|
|
|
|
;; Guile, we respect module boundaries).
|
|
|
|
|
(eval '(define round round) m)
|
|
|
|
|
(eq? (module-ref m 'round) round)))
|
2004-04-26 19:59:03 +00:00
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
(with-test-prefix "missing or extra expressions"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(define)"
|
2009-05-22 12:22:39 +02:00
|
|
|
exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(define)
|
2011-11-07 11:41:00 +01:00
|
|
|
(interaction-environment))))
|
|
|
|
|
|
|
|
|
|
(pass-if "module scoping"
|
|
|
|
|
(equal?
|
|
|
|
|
(eval
|
|
|
|
|
'(begin
|
|
|
|
|
(define-module (top-level-define/module-scoping-1)
|
|
|
|
|
#:export (define-10))
|
|
|
|
|
(define-syntax-rule (define-10 name)
|
|
|
|
|
(begin
|
|
|
|
|
(define t 10)
|
|
|
|
|
(define (name) t)))
|
|
|
|
|
(define-module (top-level-define/module-scoping-2)
|
|
|
|
|
#:use-module (top-level-define/module-scoping-1))
|
|
|
|
|
(define-10 foo)
|
|
|
|
|
(foo))
|
|
|
|
|
(current-module))
|
2011-11-07 11:44:54 +01:00
|
|
|
10))
|
|
|
|
|
|
|
|
|
|
(pass-if "module scoping, same symbolic name"
|
|
|
|
|
(equal?
|
|
|
|
|
(eval
|
|
|
|
|
'(begin
|
|
|
|
|
(define-module (top-level-define/module-scoping-3))
|
|
|
|
|
(define a 10)
|
|
|
|
|
(define-module (top-level-define/module-scoping-4)
|
|
|
|
|
#:use-module (top-level-define/module-scoping-3))
|
|
|
|
|
(define a (@@ (top-level-define/module-scoping-3) a))
|
|
|
|
|
a)
|
|
|
|
|
(current-module))
|
2011-11-07 11:47:26 +01:00
|
|
|
10))
|
|
|
|
|
|
|
|
|
|
(pass-if "module scoping, introduced names"
|
|
|
|
|
(equal?
|
|
|
|
|
(eval
|
|
|
|
|
'(begin
|
|
|
|
|
(define-module (top-level-define/module-scoping-5)
|
|
|
|
|
#:export (define-constant))
|
|
|
|
|
(define-syntax-rule (define-constant name val)
|
|
|
|
|
(begin
|
|
|
|
|
(define t val)
|
|
|
|
|
(define (name) t)))
|
|
|
|
|
(define-module (top-level-define/module-scoping-6)
|
|
|
|
|
#:use-module (top-level-define/module-scoping-5))
|
|
|
|
|
(define-constant foo 10)
|
|
|
|
|
(define-constant bar 20)
|
|
|
|
|
(foo))
|
|
|
|
|
(current-module))
|
|
|
|
|
10))
|
|
|
|
|
|
|
|
|
|
(pass-if "module scoping, duplicate introduced name"
|
|
|
|
|
(equal?
|
|
|
|
|
(eval
|
|
|
|
|
'(begin
|
|
|
|
|
(define-module (top-level-define/module-scoping-7)
|
|
|
|
|
#:export (define-constant))
|
|
|
|
|
(define-syntax-rule (define-constant name val)
|
|
|
|
|
(begin
|
|
|
|
|
(define t val)
|
|
|
|
|
(define (name) t)))
|
|
|
|
|
(define-module (top-level-define/module-scoping-8)
|
|
|
|
|
#:use-module (top-level-define/module-scoping-7))
|
|
|
|
|
(define-constant foo 10)
|
|
|
|
|
(define-constant foo 20)
|
|
|
|
|
(foo))
|
|
|
|
|
(current-module))
|
|
|
|
|
20)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2003-11-08 08:11:14 +00:00
|
|
|
(with-test-prefix "internal define"
|
|
|
|
|
|
|
|
|
|
(pass-if "internal defines become letrec"
|
|
|
|
|
(eval '(let ((a identity) (b identity) (c identity))
|
|
|
|
|
(define (a x) (if (= x 0) 'a (b (- x 1))))
|
|
|
|
|
(define (b x) (if (= x 0) 'b (c (- x 1))))
|
|
|
|
|
(define (c x) (if (= x 0) 'c (a (- x 1))))
|
|
|
|
|
(and (eq? 'a (a 0) (a 3))
|
|
|
|
|
(eq? 'b (a 1) (a 4))
|
|
|
|
|
(eq? 'c (a 2) (a 5))))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
2007-05-26 14:30:50 +00:00
|
|
|
(pass-if "binding is created before expression is evaluated"
|
|
|
|
|
;; Internal defines are equivalent to `letrec' (R5RS, Section 5.2.2).
|
|
|
|
|
(= (eval '(let ()
|
|
|
|
|
(define foo
|
|
|
|
|
(begin
|
|
|
|
|
(set! foo 1)
|
|
|
|
|
(+ foo 1)))
|
|
|
|
|
foo)
|
|
|
|
|
(interaction-environment))
|
|
|
|
|
2))
|
|
|
|
|
|
2003-11-15 12:27:54 +00:00
|
|
|
(pass-if "internal defines with begin"
|
2003-11-08 08:11:14 +00:00
|
|
|
(false-if-exception
|
|
|
|
|
(eval '(let ((a identity) (b identity) (c identity))
|
|
|
|
|
(define (a x) (if (= x 0) 'a (b (- x 1))))
|
|
|
|
|
(begin
|
|
|
|
|
(define (b x) (if (= x 0) 'b (c (- x 1)))))
|
|
|
|
|
(define (c x) (if (= x 0) 'c (a (- x 1))))
|
|
|
|
|
(and (eq? 'a (a 0) (a 3))
|
|
|
|
|
(eq? 'b (a 1) (a 4))
|
|
|
|
|
(eq? 'c (a 2) (a 5))))
|
|
|
|
|
(interaction-environment))))
|
|
|
|
|
|
2003-11-15 12:27:54 +00:00
|
|
|
(pass-if "internal defines with empty begin"
|
2003-11-08 08:11:14 +00:00
|
|
|
(false-if-exception
|
|
|
|
|
(eval '(let ((a identity) (b identity) (c identity))
|
|
|
|
|
(define (a x) (if (= x 0) 'a (b (- x 1))))
|
|
|
|
|
(begin)
|
|
|
|
|
(define (b x) (if (= x 0) 'b (c (- x 1))))
|
|
|
|
|
(define (c x) (if (= x 0) 'c (a (- x 1))))
|
|
|
|
|
(and (eq? 'a (a 0) (a 3))
|
|
|
|
|
(eq? 'b (a 1) (a 4))
|
|
|
|
|
(eq? 'c (a 2) (a 5))))
|
|
|
|
|
(interaction-environment))))
|
|
|
|
|
|
2003-11-15 11:51:17 +00:00
|
|
|
(pass-if "internal defines with macro application"
|
2003-11-09 19:07:41 +00:00
|
|
|
(false-if-exception
|
|
|
|
|
(eval '(begin
|
2003-11-15 11:51:17 +00:00
|
|
|
(defmacro my-define forms
|
2003-11-09 19:07:41 +00:00
|
|
|
(cons 'define forms))
|
2003-11-15 11:51:17 +00:00
|
|
|
(let ((a identity) (b identity) (c identity))
|
|
|
|
|
(define (a x) (if (= x 0) 'a (b (- x 1))))
|
|
|
|
|
(my-define (b x) (if (= x 0) 'b (c (- x 1))))
|
|
|
|
|
(define (c x) (if (= x 0) 'c (a (- x 1))))
|
|
|
|
|
(and (eq? 'a (a 0) (a 3))
|
|
|
|
|
(eq? 'b (a 1) (a 4))
|
|
|
|
|
(eq? 'c (a 2) (a 5)))))
|
2003-11-09 19:07:41 +00:00
|
|
|
(interaction-environment))))
|
|
|
|
|
|
2019-08-25 16:44:07 +02:00
|
|
|
(pass-if-syntax-error "empty body"
|
|
|
|
|
exception:empty-body
|
|
|
|
|
(eval '(let () (begin))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "body should end with expression"
|
|
|
|
|
exception:body-should-end-with-expr
|
2003-11-08 08:11:14 +00:00
|
|
|
(eval '(let () (define x #t))
|
2019-08-25 16:44:07 +02:00
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "mixed definitions and expressions" 256
|
|
|
|
|
((eval '(lambda (x)
|
|
|
|
|
(unless (number? x) (error "not a number" x))
|
|
|
|
|
(define (square x) (* x x))
|
|
|
|
|
(square (square x)))
|
|
|
|
|
(interaction-environment))
|
|
|
|
|
4))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "mixed definitions and expressions 2" 42
|
|
|
|
|
(eval '(let ()
|
|
|
|
|
(define (foo) (bar))
|
|
|
|
|
1
|
|
|
|
|
(define (bar) 42)
|
|
|
|
|
(foo))
|
new evaluator, y'all
* libguile/eval.c: So, ladies & gents, a new evaluator. It's similar to
the old one, in that we memoize and then evaluate, but in this
incarnation, memoization of an expression happens before evaluation,
not lazily as the expression is evaluated. This makes the evaluation
itself much cleaner, in addition to being threadsafe. In addition,
since this C evaluator will in the future just serve to bootstrap the
Scheme evaluator, we don't have to pay much concern for debugging
conveniences. So the environment is just a list of values, and the
memoizer pre-computes where it's going to find each individual value
in the environment.
Interface changes are commented below, with eval.h.
(scm_evaluator_traps): No need to reset the debug mode after rnning te
traps thing. But really, the whole traps system needs some love.
* libguile/memoize.h:
* libguile/memoize.c: New memoizer, which runs before evaluation,
checking all syntax before evaluation begins. Significantly, no
debugging information is left for lexical variables, which is not so
great for interactive debugging; perhaps we should change this to have
a var list in the future as per the classic interpreters. But it's
quite fast, and the resulting code is quite good. Also note that it
doesn't produce ilocs, memoized code is a smob whose type is in the
first word of the smob itself.
* libguile/eval.h (scm_sym_and, scm_sym_begin, scm_sym_case)
(scm_sym_cond, scm_sym_define, scm_sym_do, scm_sym_if, scm_sym_lambda)
(scm_sym_let, scm_sym_letstar, scm_sym_letrec, scm_sym_quote)
(scm_sym_quasiquote, scm_sym_unquote, scm_sym_uq_splicing, scm_sym_at)
(scm_sym_atat, scm_sym_atapply, scm_sym_atcall_cc)
(scm_sym_at_call_with_values, scm_sym_delay, scm_sym_eval_when)
(scm_sym_arrow, scm_sym_else, scm_sym_apply, scm_sym_set_x)
(scm_sym_args): Remove public declaration of these symbols.
(scm_ilookup, scm_lookupcar, scm_eval_car, scm_eval_body)
(scm_eval_args, scm_i_eval_x, scm_i_eval): Remove public declaration
of these functions.
(scm_ceval, scm_deval, scm_ceval_ptr): Remove declarations of these
deprecated functions.
(scm_i_print_iloc, scm_i_print_isym, scm_i_unmemocopy_expr)
(scm_i_unmemocopy_body): Remove declarations of these internal
functions.
(scm_primitive_eval_x, scm_eval_x): Redefine as macros for their less
destructive siblings.
* libguile/Makefile.am: Add memoize.[ch] to the build.
* libguile/debug.h (scm_debug_mode_p, scm_check_entry_p)
(scm_check_apply_p, scm_check_exit_p, scm_check_memoize_p)
(scm_debug_eframe_size): Remove these vars that were tied to the old
evaluator's execution model.
(SCM_RESET_DEBUG_MODE): Remove, no more need for this.
(SCM_MEMOIZEDP, SCM_MEMOIZED_EXP, SCM_MEMOIZED_ENV): Remove macros
referring to old memoized code representation.
(scm_local_eval, scm_procedure_environment, scm_memoized_environment)
(scm_make_memoized, scm_memoized_p): Remove functions operating on old
memoized code representation.
(scm_memcons, scm_mem_to_proc, scm_proc_to_mem): Remove debug-only
code for old evaluator.
* libguile/debug.c: Remove code to correspond with debug.h removals.
(scm_debug_options): No need to set the debug mode or frame limit
here, as we don't have C stack limits any more. Perhaps this is a bug,
but as long as we can compile eval.scm, we should be fine.
* libguile/init.c (scm_i_init_guile): Init memoize.c.
* libguile/modules.c (scm_top_level_env, scm_env_top_level)
(scm_env_module, scm_system_module_env_p): Remove these functions.
* libguile/print.c (iprin1): No more need to handle isyms. Adapt to new
form of interpreted procedures.
* libguile/procprop.c (scm_i_procedure_arity): Adapt to new form of
interpreted procedures.
* libguile/procs.c (scm_thunk_p): Adapt to new form of interpreted
procedures.
* libguile/procs.h (SCM_CLOSURE_FORMALS): Removed, this exists no more.
(SCM_CLOSURE_NUM_REQUIRED_ARGS, SCM_CLOSURE_HAS_REST_ARGS): New
accessors.
* libguile/srcprop.c (scm_source_properties, scm_source_property)
(scm_set_source_property_x): Remove special cases for memoized code.
* libguile/stacks.c (read_frame): Remove a source-property case for
interpreted code.
(NEXT_FRAME): Remove a case that I don't fully understand, that seems
to be designed to skip over apply frames. Will be obsolete in the
futures.
(read_frames): Default source value for interpreted frames to #f.
(narrow_stack): Don't pay attention to the system_module thing.
* libguile/tags.h: Remove isyms and ilocs. Whee!
* libguile/validate.h (SCM_VALIDATE_MEMOIZED): Fix to use the new
MEMOIZED_P formulation.
* module/ice-9/psyntax-pp.scm (do, quasiquote, case): Adapt for these no
longer being primitive macros.
* module/ice-9/boot-9.scm: Whitespace change, but just a poke to force a
rebuild due to and/or/cond/... not being primitives any more.
* module/ice-9/deprecated.scm (unmemoize-expr): Deprecate, it's
unmemoize-expression now.
* test-suite/tests/eval.test ("define set procedure-name"): XFAIL a
couple of tests here; I don't know what to do about them. I reckon the
expander should ensure that defined values are named.
* test-suite/tests/chars.test ("basic char handling"): Fix expected
exception when trying to apply a char.
2009-11-28 01:19:50 +01:00
|
|
|
(interaction-environment))))
|
2004-05-31 15:31:04 +00:00
|
|
|
|
2014-01-12 04:43:37 -05:00
|
|
|
(with-test-prefix "top-level define-values"
|
|
|
|
|
|
|
|
|
|
(pass-if "zero values"
|
|
|
|
|
(eval '(begin (define-values () (values))
|
|
|
|
|
#t)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "one value"
|
|
|
|
|
1
|
|
|
|
|
(eval '(begin (define-values (x) 1)
|
|
|
|
|
x)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "two values"
|
|
|
|
|
'(2 3)
|
|
|
|
|
(eval '(begin (define-values (x y) (values 2 3))
|
|
|
|
|
(list x y))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "three values"
|
|
|
|
|
'(4 5 6)
|
|
|
|
|
(eval '(begin (define-values (x y z) (values 4 5 6))
|
|
|
|
|
(list x y z))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "one value with tail"
|
|
|
|
|
'(a (b c d))
|
|
|
|
|
(eval '(begin (define-values (x . y) (values 'a 'b 'c 'd))
|
|
|
|
|
(list x y))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "two values with tail"
|
|
|
|
|
'(x y (z w))
|
|
|
|
|
(eval '(begin (define-values (x y . z) (values 'x 'y 'z 'w))
|
|
|
|
|
(list x y z))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "just tail"
|
|
|
|
|
'(1 2 3)
|
|
|
|
|
(eval '(begin (define-values x (values 1 2 3))
|
|
|
|
|
x)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "expected 0 values, got 1"
|
2014-02-07 15:15:08 +01:00
|
|
|
exception:wrong-number-of-values
|
2014-01-12 04:43:37 -05:00
|
|
|
(eval '(define-values () 1)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "expected 1 value, got 0"
|
2014-02-07 15:15:08 +01:00
|
|
|
exception:wrong-number-of-values
|
2014-01-12 04:43:37 -05:00
|
|
|
(eval '(define-values (x) (values))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "expected 1 value, got 2"
|
2014-02-07 15:15:08 +01:00
|
|
|
exception:wrong-number-of-values
|
2014-01-12 04:43:37 -05:00
|
|
|
(eval '(define-values (x) (values 1 2))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "expected 1 value with tail, got 0"
|
2014-02-07 15:15:08 +01:00
|
|
|
exception:wrong-number-of-values
|
2014-01-12 04:43:37 -05:00
|
|
|
(eval '(define-values (x . y) (values))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "expected 2 value with tail, got 1"
|
2014-02-07 15:15:08 +01:00
|
|
|
exception:wrong-number-of-values
|
2014-01-12 04:43:37 -05:00
|
|
|
(eval '(define-values (x y . z) 1)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if "redefinition"
|
|
|
|
|
(let ((m (make-module)))
|
|
|
|
|
(beautify-user-module! m)
|
|
|
|
|
|
|
|
|
|
;; The previous values of `floor' and `round' must still be
|
|
|
|
|
;; visible at the time the new `floor' and `round' are defined.
|
|
|
|
|
(eval '(define-values (floor round) (values floor round)) m)
|
|
|
|
|
(and (eq? (module-ref m 'floor) floor)
|
|
|
|
|
(eq? (module-ref m 'round) round))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "missing expression"
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "(define-values)"
|
|
|
|
|
exception:generic-syncase-error
|
|
|
|
|
(eval '(define-values)
|
|
|
|
|
(interaction-environment)))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "internal define-values"
|
|
|
|
|
|
|
|
|
|
(pass-if "zero values"
|
|
|
|
|
(let ()
|
|
|
|
|
(define-values () (values))
|
|
|
|
|
#t))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "one value"
|
|
|
|
|
1
|
|
|
|
|
(let ()
|
|
|
|
|
(define-values (x) 1)
|
|
|
|
|
x))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "two values"
|
|
|
|
|
'(2 3)
|
|
|
|
|
(let ()
|
|
|
|
|
(define-values (x y) (values 2 3))
|
|
|
|
|
(list x y)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "three values"
|
|
|
|
|
'(4 5 6)
|
|
|
|
|
(let ()
|
|
|
|
|
(define-values (x y z) (values 4 5 6))
|
|
|
|
|
(list x y z)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "one value with tail"
|
|
|
|
|
'(a (b c d))
|
|
|
|
|
(let ()
|
|
|
|
|
(define-values (x . y) (values 'a 'b 'c 'd))
|
|
|
|
|
(list x y)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "two values with tail"
|
|
|
|
|
'(x y (z w))
|
|
|
|
|
(let ()
|
|
|
|
|
(define-values (x y . z) (values 'x 'y 'z 'w))
|
|
|
|
|
(list x y z)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "just tail"
|
|
|
|
|
'(1 2 3)
|
|
|
|
|
(let ()
|
|
|
|
|
(define-values x (values 1 2 3))
|
|
|
|
|
x))
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "expected 0 values, got 1"
|
2014-02-07 15:15:08 +01:00
|
|
|
exception:wrong-number-of-values
|
2014-01-12 04:43:37 -05:00
|
|
|
(eval '(let ()
|
|
|
|
|
(define-values () 1)
|
|
|
|
|
#f)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "expected 1 value, got 0"
|
2014-02-07 15:15:08 +01:00
|
|
|
exception:wrong-number-of-values
|
2014-01-12 04:43:37 -05:00
|
|
|
(eval '(let ()
|
|
|
|
|
(define-values (x) (values))
|
|
|
|
|
#f)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "expected 1 value, got 2"
|
2014-02-07 15:15:08 +01:00
|
|
|
exception:wrong-number-of-values
|
2014-01-12 04:43:37 -05:00
|
|
|
(eval '(let ()
|
|
|
|
|
(define-values (x) (values 1 2))
|
|
|
|
|
#f)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "expected 1 value with tail, got 0"
|
2014-02-07 15:15:08 +01:00
|
|
|
exception:wrong-number-of-values
|
2014-01-12 04:43:37 -05:00
|
|
|
(eval '(let ()
|
|
|
|
|
(define-values (x . y) (values))
|
|
|
|
|
#f)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "expected 2 value with tail, got 1"
|
2014-02-07 15:15:08 +01:00
|
|
|
exception:wrong-number-of-values
|
2014-01-12 04:43:37 -05:00
|
|
|
(eval '(let ()
|
|
|
|
|
(define-values (x y . z) 1)
|
|
|
|
|
#f)
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "missing expression"
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "(define-values)"
|
|
|
|
|
exception:generic-syncase-error
|
|
|
|
|
(eval '(let ()
|
|
|
|
|
(define-values)
|
|
|
|
|
#f)
|
|
|
|
|
(interaction-environment)))))
|
|
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
(with-test-prefix "set!"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "missing or extra expressions"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(set!)"
|
2009-05-22 12:22:39 +02:00
|
|
|
exception:bad-set!
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set!)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(set! 1)"
|
2009-05-22 12:22:39 +02:00
|
|
|
exception:bad-set!
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(set! 1 2 3)"
|
2009-05-22 12:22:39 +02:00
|
|
|
exception:bad-set!
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! 1 2 3)
|
|
|
|
|
(interaction-environment))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "bad variable"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(set! \"\" #t)"
|
2009-05-22 12:22:39 +02:00
|
|
|
exception:bad-set!
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! "" #t)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(set! 1 #t)"
|
2009-05-22 12:22:39 +02:00
|
|
|
exception:bad-set!
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! 1 #t)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(set! #t #f)"
|
2009-05-22 12:22:39 +02:00
|
|
|
exception:bad-set!
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! #t #f)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(set! #f #t)"
|
2009-05-22 12:22:39 +02:00
|
|
|
exception:bad-set!
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! #f #t)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(set! #\\space #f)"
|
2009-05-22 12:22:39 +02:00
|
|
|
exception:bad-set!
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! #\space #f)
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "quote"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "missing or extra expression"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(quote)"
|
2009-05-22 12:22:39 +02:00
|
|
|
exception:bad-quote
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(quote)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "(quote a b)"
|
2009-05-22 12:22:39 +02:00
|
|
|
exception:bad-quote
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(quote a b)
|
|
|
|
|
(interaction-environment)))))
|
2003-08-12 21:39:30 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "while"
|
|
|
|
|
|
|
|
|
|
(define (unreachable)
|
|
|
|
|
(error "unreachable code has been reached!"))
|
|
|
|
|
|
|
|
|
|
;; Return a new procedure COND which when called (COND) will return #t the
|
|
|
|
|
;; first N times, then #f, then any further call is an error. N=0 is
|
|
|
|
|
;; allowed, in which case #f is returned by the first call.
|
|
|
|
|
(define (make-iterations-cond n)
|
|
|
|
|
(lambda ()
|
|
|
|
|
(cond ((not n)
|
|
|
|
|
(error "oops, condition re-tested after giving false"))
|
|
|
|
|
((= 0 n)
|
|
|
|
|
(set! n #f)
|
|
|
|
|
#f)
|
|
|
|
|
(else
|
|
|
|
|
(set! n (1- n))
|
|
|
|
|
#t))))
|
|
|
|
|
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "too few args" exception:generic-syncase-error
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(while) (interaction-environment)))
|
2003-08-12 21:39:30 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "empty body"
|
|
|
|
|
(do ((n 0 (1+ n)))
|
|
|
|
|
((> n 5))
|
|
|
|
|
(pass-if n
|
2009-05-18 23:45:35 +02:00
|
|
|
(eval `(letrec ((make-iterations-cond
|
|
|
|
|
(lambda (n)
|
|
|
|
|
(lambda ()
|
|
|
|
|
(cond ((not n)
|
|
|
|
|
(error "oops, condition re-tested after giving false"))
|
|
|
|
|
((= 0 n)
|
|
|
|
|
(set! n #f)
|
|
|
|
|
#f)
|
|
|
|
|
(else
|
|
|
|
|
(set! n (1- n))
|
|
|
|
|
#t))))))
|
|
|
|
|
(let ((cond (make-iterations-cond ,n)))
|
|
|
|
|
(while (cond))
|
|
|
|
|
#t))
|
|
|
|
|
(interaction-environment)))))
|
2003-08-12 21:39:30 +00:00
|
|
|
|
|
|
|
|
(pass-if "initially false"
|
|
|
|
|
(while #f
|
|
|
|
|
(unreachable))
|
|
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "iterations"
|
|
|
|
|
(do ((n 0 (1+ n)))
|
|
|
|
|
((> n 5))
|
|
|
|
|
(pass-if n
|
|
|
|
|
(let ((cond (make-iterations-cond n))
|
|
|
|
|
(i 0))
|
|
|
|
|
(while (cond)
|
|
|
|
|
(set! i (1+ i)))
|
|
|
|
|
(= i n)))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "break"
|
|
|
|
|
|
2011-04-28 13:08:22 +02:00
|
|
|
(pass-if "normal return"
|
|
|
|
|
(not (while #f (error "not reached"))))
|
|
|
|
|
|
|
|
|
|
(pass-if "no args"
|
|
|
|
|
(while #t (break)))
|
|
|
|
|
|
|
|
|
|
(pass-if "multiple values"
|
|
|
|
|
(equal? '(1 2 3)
|
|
|
|
|
(call-with-values
|
|
|
|
|
(lambda () (while #t (break 1 2 3)))
|
|
|
|
|
list)))
|
|
|
|
|
|
2003-08-12 21:39:30 +00:00
|
|
|
(with-test-prefix "from cond"
|
|
|
|
|
(pass-if "first"
|
|
|
|
|
(while (begin
|
|
|
|
|
(break)
|
|
|
|
|
(unreachable))
|
|
|
|
|
(unreachable))
|
|
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(do ((n 0 (1+ n)))
|
|
|
|
|
((> n 5))
|
|
|
|
|
(pass-if n
|
|
|
|
|
(let ((cond (make-iterations-cond n))
|
|
|
|
|
(i 0))
|
|
|
|
|
(while (if (cond)
|
|
|
|
|
#t
|
|
|
|
|
(begin
|
|
|
|
|
(break)
|
|
|
|
|
(unreachable)))
|
|
|
|
|
(set! i (1+ i)))
|
|
|
|
|
(= i n)))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "from body"
|
|
|
|
|
(pass-if "first"
|
|
|
|
|
(while #t
|
|
|
|
|
(break)
|
|
|
|
|
(unreachable))
|
|
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(do ((n 0 (1+ n)))
|
|
|
|
|
((> n 5))
|
|
|
|
|
(pass-if n
|
|
|
|
|
(let ((cond (make-iterations-cond n))
|
|
|
|
|
(i 0))
|
|
|
|
|
(while #t
|
|
|
|
|
(if (not (cond))
|
|
|
|
|
(begin
|
|
|
|
|
(break)
|
|
|
|
|
(unreachable)))
|
|
|
|
|
(set! i (1+ i)))
|
|
|
|
|
(= i n)))))
|
|
|
|
|
|
|
|
|
|
(pass-if "from nested"
|
|
|
|
|
(while #t
|
|
|
|
|
(let ((outer-break break))
|
|
|
|
|
(while #t
|
|
|
|
|
(outer-break)
|
|
|
|
|
(unreachable)))
|
|
|
|
|
(unreachable))
|
2003-08-17 00:40:33 +00:00
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(pass-if "from recursive"
|
|
|
|
|
(let ((outer-break #f))
|
|
|
|
|
(define (r n)
|
|
|
|
|
(while #t
|
|
|
|
|
(if (eq? n 'outer)
|
|
|
|
|
(begin
|
|
|
|
|
(set! outer-break break)
|
|
|
|
|
(r 'inner))
|
|
|
|
|
(begin
|
|
|
|
|
(outer-break)
|
|
|
|
|
(unreachable))))
|
|
|
|
|
(if (eq? n 'inner)
|
|
|
|
|
(error "broke only from inner loop")))
|
|
|
|
|
(r 'outer))
|
2003-08-12 21:39:30 +00:00
|
|
|
#t))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "continue"
|
|
|
|
|
|
2010-11-18 11:04:15 +01:00
|
|
|
(pass-if-syntax-error "too many args" exception:too-many-args
|
2009-05-22 12:22:39 +02:00
|
|
|
(eval '(while #t
|
|
|
|
|
(continue 1))
|
|
|
|
|
(interaction-environment)))
|
2003-08-12 21:39:30 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "from cond"
|
|
|
|
|
(do ((n 0 (1+ n)))
|
|
|
|
|
((> n 5))
|
|
|
|
|
(pass-if n
|
|
|
|
|
(let ((cond (make-iterations-cond n))
|
|
|
|
|
(i 0))
|
|
|
|
|
(while (if (cond)
|
|
|
|
|
(begin
|
|
|
|
|
(set! i (1+ i))
|
|
|
|
|
(continue)
|
|
|
|
|
(unreachable))
|
|
|
|
|
#f)
|
|
|
|
|
(unreachable))
|
|
|
|
|
(= i n)))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "from body"
|
|
|
|
|
(do ((n 0 (1+ n)))
|
|
|
|
|
((> n 5))
|
|
|
|
|
(pass-if n
|
|
|
|
|
(let ((cond (make-iterations-cond n))
|
|
|
|
|
(i 0))
|
|
|
|
|
(while (cond)
|
|
|
|
|
(set! i (1+ i))
|
|
|
|
|
(continue)
|
|
|
|
|
(unreachable))
|
|
|
|
|
(= i n)))))
|
|
|
|
|
|
|
|
|
|
(pass-if "from nested"
|
|
|
|
|
(let ((cond (make-iterations-cond 3)))
|
|
|
|
|
(while (cond)
|
|
|
|
|
(let ((outer-continue continue))
|
|
|
|
|
(while #t
|
|
|
|
|
(outer-continue)
|
|
|
|
|
(unreachable)))))
|
2003-08-17 00:40:33 +00:00
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(pass-if "from recursive"
|
|
|
|
|
(let ((outer-continue #f))
|
|
|
|
|
(define (r n)
|
|
|
|
|
(let ((cond (make-iterations-cond 3))
|
|
|
|
|
(first #t))
|
|
|
|
|
(while (begin
|
|
|
|
|
(if (and (not first)
|
|
|
|
|
(eq? n 'inner))
|
|
|
|
|
(error "continued only to inner loop"))
|
|
|
|
|
(cond))
|
|
|
|
|
(set! first #f)
|
|
|
|
|
(if (eq? n 'outer)
|
|
|
|
|
(begin
|
|
|
|
|
(set! outer-continue continue)
|
|
|
|
|
(r 'inner))
|
|
|
|
|
(begin
|
|
|
|
|
(outer-continue)
|
|
|
|
|
(unreachable))))))
|
|
|
|
|
(r 'outer))
|
2003-08-12 21:39:30 +00:00
|
|
|
#t)))
|
2013-12-13 12:53:24 -05:00
|
|
|
|
2013-12-18 18:49:37 -05:00
|
|
|
(with-test-prefix "syntax-rules"
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "custom ellipsis within normal ellipsis"
|
|
|
|
|
'((((a x) (a y) (a …))
|
|
|
|
|
((b x) (b y) (b …))
|
|
|
|
|
((c x) (c y) (c …)))
|
|
|
|
|
(((a x) (b x) (c x))
|
|
|
|
|
((a y) (b y) (c y))
|
|
|
|
|
((a …) (b …) (c …))))
|
|
|
|
|
(let ()
|
|
|
|
|
(define-syntax foo
|
|
|
|
|
(syntax-rules ()
|
|
|
|
|
((_ y ...)
|
|
|
|
|
(syntax-rules … ()
|
|
|
|
|
((_ x …)
|
|
|
|
|
'((((x y) ...) …)
|
|
|
|
|
(((x y) …) ...)))))))
|
|
|
|
|
(define-syntax bar (foo x y …))
|
|
|
|
|
(bar a b c)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "normal ellipsis within custom ellipsis"
|
|
|
|
|
'((((a x) (a y) (a z))
|
|
|
|
|
((b x) (b y) (b z))
|
|
|
|
|
((c x) (c y) (c z)))
|
|
|
|
|
(((a x) (b x) (c x))
|
|
|
|
|
((a y) (b y) (c y))
|
|
|
|
|
((a z) (b z) (c z))))
|
|
|
|
|
(let ()
|
|
|
|
|
(define-syntax foo
|
|
|
|
|
(syntax-rules … ()
|
|
|
|
|
((_ y …)
|
|
|
|
|
(syntax-rules ()
|
|
|
|
|
((_ x ...)
|
|
|
|
|
'((((x y) …) ...)
|
|
|
|
|
(((x y) ...) …)))))))
|
|
|
|
|
(define-syntax bar (foo x y z))
|
2014-01-15 03:08:32 -05:00
|
|
|
(bar a b c)))
|
|
|
|
|
|
|
|
|
|
;; This test is given in SRFI-46.
|
|
|
|
|
(pass-if-equal "custom ellipsis is handled hygienically"
|
|
|
|
|
'((1) 2 (3) (4))
|
|
|
|
|
(let-syntax
|
|
|
|
|
((f (syntax-rules ()
|
|
|
|
|
((f ?e)
|
|
|
|
|
(let-syntax
|
|
|
|
|
((g (syntax-rules --- ()
|
|
|
|
|
((g (??x ?e) (??y ---))
|
|
|
|
|
'((??x) ?e (??y) ---)))))
|
|
|
|
|
(g (1 2) (3 4)))))))
|
|
|
|
|
(f ---))))
|
2013-12-18 18:49:37 -05:00
|
|
|
|
2013-12-19 13:22:50 -05:00
|
|
|
(with-test-prefix "syntax-error"
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "outside of macro without args"
|
|
|
|
|
"test error"
|
|
|
|
|
(eval '(syntax-error "test error")
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "outside of macro with args"
|
|
|
|
|
"test error x \\(y z\\)"
|
|
|
|
|
(eval '(syntax-error "test error" x (y z))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "within macro"
|
|
|
|
|
'(simple-let
|
|
|
|
|
"expected an identifier but got (z1 z2)"
|
|
|
|
|
(simple-let ((y (* x x))
|
|
|
|
|
((z1 z2) (values x x)))
|
|
|
|
|
(+ y 1)))
|
|
|
|
|
(catch 'syntax-error
|
|
|
|
|
(lambda ()
|
|
|
|
|
(eval '(let ()
|
|
|
|
|
(define-syntax simple-let
|
|
|
|
|
(syntax-rules ()
|
|
|
|
|
((_ (head ... ((x . y) val) . tail)
|
|
|
|
|
body1 body2 ...)
|
|
|
|
|
(syntax-error
|
|
|
|
|
"expected an identifier but got"
|
|
|
|
|
(x . y)))
|
|
|
|
|
((_ ((name val) ...) body1 body2 ...)
|
|
|
|
|
((lambda (name ...) body1 body2 ...)
|
|
|
|
|
val ...))))
|
|
|
|
|
(define (foo x)
|
|
|
|
|
(simple-let ((y (* x x))
|
|
|
|
|
((z1 z2) (values x x)))
|
|
|
|
|
(+ y 1)))
|
|
|
|
|
foo)
|
|
|
|
|
(interaction-environment))
|
|
|
|
|
(error "expected syntax-error exception"))
|
|
|
|
|
(lambda (k who what where form . maybe-subform)
|
|
|
|
|
(list who what form)))))
|
|
|
|
|
|
2013-12-13 12:53:24 -05:00
|
|
|
(with-test-prefix "syntax-case"
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "duplicate pattern variable"
|
|
|
|
|
'(syntax-case . "duplicate pattern variable")
|
|
|
|
|
(eval '(lambda (e)
|
|
|
|
|
(syntax-case e ()
|
|
|
|
|
((a b c d e d f) #f)))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "misplaced ellipses"
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "bare ellipsis"
|
|
|
|
|
'(syntax-case . "misplaced ellipsis")
|
|
|
|
|
(eval '(lambda (e)
|
|
|
|
|
(syntax-case e ()
|
|
|
|
|
(... #f)))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "ellipsis singleton"
|
|
|
|
|
'(syntax-case . "misplaced ellipsis")
|
|
|
|
|
(eval '(lambda (e)
|
|
|
|
|
(syntax-case e ()
|
|
|
|
|
((...) #f)))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "ellipsis in car"
|
|
|
|
|
'(syntax-case . "misplaced ellipsis")
|
|
|
|
|
(eval '(lambda (e)
|
|
|
|
|
(syntax-case e ()
|
|
|
|
|
((... . _) #f)))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "ellipsis in cdr"
|
|
|
|
|
'(syntax-case . "misplaced ellipsis")
|
|
|
|
|
(eval '(lambda (e)
|
|
|
|
|
(syntax-case e ()
|
|
|
|
|
((_ . ...) #f)))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "two ellipses in the same list"
|
|
|
|
|
'(syntax-case . "misplaced ellipsis")
|
|
|
|
|
(eval '(lambda (e)
|
|
|
|
|
(syntax-case e ()
|
|
|
|
|
((x ... y ...) #f)))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-syntax-error "three ellipses in the same list"
|
|
|
|
|
'(syntax-case . "misplaced ellipsis")
|
|
|
|
|
(eval '(lambda (e)
|
|
|
|
|
(syntax-case e ()
|
|
|
|
|
((x ... y ... z ...) #f)))
|
|
|
|
|
(interaction-environment)))))
|
|
|
|
|
|
2013-12-18 18:49:37 -05:00
|
|
|
(with-test-prefix "with-ellipsis"
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "simple"
|
|
|
|
|
'(a 1 2 3)
|
|
|
|
|
(let ()
|
|
|
|
|
(define-syntax define-quotation-macros
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(syntax-case x ()
|
|
|
|
|
((_ (macro-name head-symbol) ...)
|
|
|
|
|
#'(begin (define-syntax macro-name
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(with-ellipsis …
|
|
|
|
|
(syntax-case x ()
|
|
|
|
|
((_ x …)
|
|
|
|
|
#'(quote (head-symbol x …)))))))
|
|
|
|
|
...)))))
|
|
|
|
|
(define-quotation-macros (quote-a a) (quote-b b))
|
|
|
|
|
(quote-a 1 2 3)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "disables normal ellipsis"
|
|
|
|
|
'(a ...)
|
|
|
|
|
(let ()
|
|
|
|
|
(define-syntax foo
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(with-ellipsis …
|
|
|
|
|
(syntax-case x ()
|
|
|
|
|
((_)
|
|
|
|
|
#'(quote (a ...)))))))
|
|
|
|
|
(foo)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "doesn't affect ellipsis for generated code"
|
|
|
|
|
'(a b c)
|
|
|
|
|
(let ()
|
|
|
|
|
(define-syntax quotation-macro
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(with-ellipsis …
|
|
|
|
|
(syntax-case x ()
|
|
|
|
|
((_)
|
|
|
|
|
#'(lambda (x)
|
|
|
|
|
(syntax-case x ()
|
|
|
|
|
((_ x ...)
|
|
|
|
|
#'(quote (x ...))))))))))
|
|
|
|
|
(define-syntax kwote (quotation-macro))
|
|
|
|
|
(kwote a b c)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "propagates into syntax binders"
|
|
|
|
|
'(a b c)
|
|
|
|
|
(let ()
|
|
|
|
|
(with-ellipsis …
|
|
|
|
|
(define-syntax kwote
|
|
|
|
|
(lambda (x)
|
|
|
|
|
(syntax-case x ()
|
|
|
|
|
((_ x …)
|
|
|
|
|
#'(quote (x …))))))
|
|
|
|
|
(kwote a b c))))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "works with local-eval"
|
|
|
|
|
5
|
|
|
|
|
(let ((env (with-ellipsis … (the-environment))))
|
|
|
|
|
(local-eval '(syntax-case #'(a b c d e) ()
|
|
|
|
|
((x …)
|
|
|
|
|
(length #'(x …))))
|
|
|
|
|
env))))
|
|
|
|
|
|
2017-04-21 11:04:08 +02:00
|
|
|
(with-test-prefix "syntax objects"
|
|
|
|
|
(let ((interpreted (eval '#'(foo bar baz) (current-module)))
|
|
|
|
|
(interpreted-bis (eval '#'(foo bar baz) (current-module)))
|
|
|
|
|
(compiled ((@ (system base compile) compile) '#'(foo bar baz)
|
|
|
|
|
#:env (current-module))))
|
|
|
|
|
;; Guile's expander doesn't wrap lists.
|
|
|
|
|
(pass-if "interpreted syntax object?"
|
|
|
|
|
(and (list? interpreted)
|
|
|
|
|
(and-map syntax? interpreted)))
|
|
|
|
|
(pass-if "compiled syntax object?"
|
|
|
|
|
(and (list? compiled)
|
|
|
|
|
(and-map syntax? compiled)))
|
|
|
|
|
|
|
|
|
|
(pass-if "interpreted syntax objects are not vectors"
|
|
|
|
|
(not (vector? interpreted)))
|
|
|
|
|
(pass-if "compiled syntax objects are not vectors"
|
|
|
|
|
(not (vector? compiled)))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "syntax objects comparable with equal? (eval/eval)"
|
|
|
|
|
interpreted interpreted-bis)
|
|
|
|
|
(pass-if-equal "syntax objects comparable with equal? (eval/compile)"
|
|
|
|
|
interpreted compiled)
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "syntax objects hash the same (eval/eval)"
|
|
|
|
|
(hash interpreted most-positive-fixnum)
|
|
|
|
|
(hash interpreted-bis most-positive-fixnum))
|
|
|
|
|
|
|
|
|
|
(pass-if-equal "syntax objects hash the same (eval/compile)"
|
|
|
|
|
(hash interpreted most-positive-fixnum)
|
|
|
|
|
(hash compiled most-positive-fixnum))))
|
|
|
|
|
|
|
|
|
|
|
2013-12-13 12:53:24 -05:00
|
|
|
;;; Local Variables:
|
|
|
|
|
;;; eval: (put 'pass-if-syntax-error 'scheme-indent-function 1)
|
2013-12-18 18:49:37 -05:00
|
|
|
;;; eval: (put 'with-ellipsis 'scheme-indent-function 1)
|
2013-12-13 12:53:24 -05:00
|
|
|
;;; End:
|