1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

Baseline compiler no longer crashes on (not (list 1 2)).

Fixes <https://bugs.gnu.org/58217>.

* module/language/tree-il/compile-bytecode.scm (canonicalize)
[finish-conditional](predicate?): Do not assume 'lookup-primitive'
returns true.
* test-suite/tests/compiler.test ("regression tests")
["(not (list 1 2))"]: New test.
This commit is contained in:
Ludovic Courtès 2022-10-01 15:36:21 +02:00
parent df86a2a8c8
commit e2797f529b
3 changed files with 12 additions and 2 deletions

2
NEWS
View file

@ -61,6 +61,8 @@ for use with `setsockopt'.
(<https://bugs.gnu.org/49223>)
** 'primitive-load' opens files as O_CLOEXEC
(<https://bugs.gnu.org/57567>)
** Baseline compiler no longer crashes on (not (list 1 2))
(<https://bugs.gnu.org/58217>)
Changes in 3.0.8 (since 3.0.7)

View file

@ -409,7 +409,9 @@
(define (finish-conditional exp)
(define (true? x) (match x (($ <const> _ val) val) (_ #f)))
(define (false? x) (match x (($ <const> _ val) (not val)) (_ #f)))
(define (predicate? name) (primitive-predicate? (lookup-primitive name)))
(define (predicate? name)
(and=> (lookup-primitive name) primitive-predicate?))
(match exp
(($ <conditional> src ($ <conditional> _ test (? true?) (? false?))
consequent alternate)

View file

@ -235,7 +235,13 @@
(pass-if "Chained comparisons"
(not (compile
'(false-if-exception (< 'not-a-number))))))
'(false-if-exception (< 'not-a-number)))))
(pass-if-equal "(not (list 1 2))" ;https://bugs.gnu.org/58217
'(#f #f)
;; The baseline compiler (-O0 and -O1) in 3.0.8 would crash.
(list (compile '(not (list 1 2)) #:optimization-level 2)
(compile '(not (list 1 2)) #:optimization-level 0))))
(with-test-prefix "prompt body slot allocation"
(define test-code