mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Fix (< 'foo) compilation
* module/language/tree-il/primitives.scm (expand-chained-comparisons): Fix (< 'foo) compilation. * test-suite/tests/compiler.test ("regression tests"): Add test case.
This commit is contained in:
parent
2546849642
commit
0472af4c58
2 changed files with 11 additions and 2 deletions
|
@ -579,7 +579,12 @@
|
|||
(define (expand-chained-comparisons prim)
|
||||
(case-lambda
|
||||
((src) (make-const src #t))
|
||||
((src a) (make-const src #t))
|
||||
((src a)
|
||||
;; (< x) -> (begin (< x 0) #t). Residualizes side-effects from x
|
||||
;; and, for numeric comparisons, checks that x is a number.
|
||||
(make-seq src
|
||||
(make-primcall src prim (list a (make-const src 0)))
|
||||
(make-const src #t)))
|
||||
((src a b) #f)
|
||||
((src a b . rest)
|
||||
(make-conditional src (make-primcall src prim (list a b))
|
||||
|
|
|
@ -209,4 +209,8 @@
|
|||
'(begin
|
||||
(define x (list 1))
|
||||
(define x (car x))
|
||||
x))))
|
||||
x)))
|
||||
|
||||
(pass-if "Chained comparisons"
|
||||
(not (compile
|
||||
'(false-if-exception (< 'not-a-number))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue