mes: Evaluate test of COND only once.
* module/mes/base-0.mes (cond): Evaluate test of COND only once. Fixes cond tests with side effects (Nyacc). * tests/base.test ("cond side effect"): Test it.
This commit is contained in:
parent
c60e79ae11
commit
5d68fc44ba
|
@ -63,8 +63,8 @@
|
|||
(if (pair? (cdr (car clauses)))
|
||||
(if (eq? (car (cdr (car clauses))) '=>)
|
||||
(append2 (cdr (cdr (car clauses))) '(test))
|
||||
(list (cons 'lambda (cons '() (car clauses)))))
|
||||
(list (cons 'lambda (cons '() (car clauses)))))
|
||||
(list (cons 'lambda (cons '() (cons 'test (cdar clauses))))))
|
||||
(list (cons 'lambda (cons '() (cons 'test (cdar clauses))))))
|
||||
(if (pair? (cdr clauses))
|
||||
(cons 'cond (cdr clauses)))))))
|
||||
(car (car clauses)))))
|
||||
|
|
|
@ -61,6 +61,10 @@ exit $?
|
|||
(pass-if "cond 2" (seq? (cond (#f)) *unspecified*))
|
||||
(pass-if "cond 3" (seq? (cond (#t 0)) 0))
|
||||
(pass-if "cond 3" (seq? (cond (#f 1) (#t 0)) 0))
|
||||
(pass-if-equal "cond side effect"
|
||||
1
|
||||
(let ((i 0))
|
||||
(cond ((set! i (1+ i)) i))))
|
||||
(pass-if-equal "cond => "
|
||||
0 (let ((lst '(0 1 2)))
|
||||
(define (next)
|
||||
|
|
Loading…
Reference in a new issue