GNU bug report logs - #58217
tree-il->bytecode compilation of (not (list …)) fails

Previous Next

Package: guile;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Sat, 1 Oct 2022 10:28:02 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 58217 in the body.
You can then email your comments to 58217 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#58217; Package guile. (Sat, 01 Oct 2022 10:28:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludo <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sat, 01 Oct 2022 10:28:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: bug-guile <at> gnu.org
Subject: tree-il->bytecode compilation of (not (list …)) fails
Date: Sat, 01 Oct 2022 12:27:30 +0200
Hi,

I stumbled upon this bug of the baseline compiler:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (compile '(not (list 1 2)) #:optimization-level 2)
$3 = #f
scheme@(guile-user)> (compile '(not (list 1 2)) #:optimization-level 1)
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure struct-vtable: Wrong type argument in position 1 (expecting struct): #f

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt
In system/base/compile.scm:
   352:28  5 (compile _ #:from _ #:to _ #:env _ #:optimization-level _ #:warning-level _ #:opts _)
   265:44  4 (_ _ _)
   261:27  3 (_ _ _)
In language/tree-il/compile-bytecode.scm:
  1386:14  2 (compile-bytecode #<tree-il (primcall not (primcall list (const 1) (const 2)))> #<module (#{ g446}#) …> …)
   412:30  1 (_ _)
In ice-9/boot-9.scm:
  1685:16  0 (raise-exception _ #:continuable? _)
scheme@(guile-user) [1]> (version)
$4 = "3.0.8"
--8<---------------cut here---------------end--------------->8---

The exception is raised in the ‘predicate?’ call below, where
(lookup-primitive 'list) returns #f:

  (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)))
    (match exp
      (($ <conditional> src ($ <conditional> _ test (? true?) (? false?))
          consequent alternate)
       (finish-conditional (make-conditional src test consequent alternate)))
      (($ <conditional> src ($ <conditional> _ test (? false?) (? true?))
          consequent alternate)
       (finish-conditional (make-conditional src test alternate consequent)))
      (($ <conditional> src ($ <primcall> _ (? predicate?)))
       exp)
      (($ <conditional> src test consequent alternate)
       (make-conditional src (make-primcall src 'false? (list test))
                         alternate consequent))))

I believe this is fixed by changing ‘predicate?’ to:

    (define (predicate? name)
      (and=> (lookup-primitive name) primitive-predicate?))

Thoughts?

Ludo’.




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Sat, 01 Oct 2022 14:03:02 GMT) Full text and rfc822 format available.

Notification sent to Ludovic Courtès <ludo <at> gnu.org>:
bug acknowledged by developer. (Sat, 01 Oct 2022 14:03:02 GMT) Full text and rfc822 format available.

Message #10 received at 58217-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: 58217-done <at> debbugs.gnu.org
Subject: Re: bug#58217: tree-il->bytecode compilation of (not (list
 …)) fails
Date: Sat, 01 Oct 2022 16:02:37 +0200
Ludovic Courtès <ludo <at> gnu.org> skribis:

> I believe this is fixed by changing ‘predicate?’ to:
>
>     (define (predicate? name)
>       (and=> (lookup-primitive name) primitive-predicate?))

Done in e2797f529b8934b0a11b9f6aebbf937b183ece77!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 30 Oct 2022 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 291 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.