1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 20:30:28 +02:00

Fix order-of-side-effects bug in (eq? x y z) expansion

* module/language/tree-il/primitives.scm (bind-lexicals): New helper.
(expand-eq, expand-chained-comparisons): Ensure all arguments are
eagerly evaluated.  Previously an intermediate #f result would shortcut
the evaluation.
* test-suite/tests/compiler.test ("size effects in multi-arg eq / <"):
Add test.
This commit is contained in:
Andy Wingo 2022-12-01 12:56:51 +01:00
parent c7fa78fc75
commit d184d09346
2 changed files with 45 additions and 12 deletions

View file

@ -401,6 +401,17 @@
(pass-if-equal "foo bar" 'qux (test-proc 'foo 'bar))
(pass-if-equal "foo two" 'foo (test-proc 'foo 'two)))
(with-test-prefix "size effects in multi-arg eq / <"
(pass-if-equal "eq?" 42
(compile '(catch 'foo
(lambda () (= 0 1 (throw 'foo)))
(lambda (k) 42))))
(pass-if-equal "<" 42
(compile '(catch 'foo
(lambda () (< 0 -1 (throw 'foo)))
(lambda (k) 42)))))
(with-test-prefix "read-and-compile tree-il"
(let ((code
"\