From: Jean Abou Samra <jean@abou-samra.fr>
To: 64508@debbugs.gnu.org
Subject: bug#64508: Optimization of "-" function is incorrect in presence of GOOPS overloading
Date: Fri, 07 Jul 2023 14:56:15 +0200 [thread overview]
Message-ID: <6f7bb96b48e6a80287b9c2f827605b4c3c5bd17b.camel@abou-samra.fr> (raw)
[-- Attachment #1: Type: text/plain, Size: 1611 bytes --]
The following code demonstrates that when byte-compiling (but not when
interpreting), the call (- x) is transformed into (- 0 x). This results
in failure of custom - methods defined via GOOPS.
I think this says it all:
$ guile3.0
GNU Guile 3.0.7 [...]
scheme@(guile-user)> ,optimize (- x)
$1 = (- 0 x)
The longer version:
$ cat minus.scm
(use-modules (oop goops))
(define-class <Foo> ()
(bar #:init-keyword #:bar))
(define-method (- (x <Foo>))
(make <Foo> #:bar (- (slot-ref x 'bar))))
(display (slot-ref (- (make <Foo> #:bar 5))
'bar))
(newline)
$ guile3.0 --no-auto-compile minus.scm
-5
$ guile3.0 minus.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /home/jean/tmp/minus.scm
;;; compiled /home/jean/.cache/guile/ccache/3.0-LE-8-
4.5/home/jean/tmp/minus.scm.go
Backtrace:
In ice-9/boot-9.scm:
1752:10 8 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
7 (apply-smob/0 #<thunk 7f569a4a0f60>)
In ice-9/boot-9.scm:
724:2 6 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
619:8 5 (_ #(#(#<directory (guile-user) 7f569a499c80>)))
In ice-9/boot-9.scm:
2835:4 4 (save-module-excursion _)
4380:12 3 (_)
In /home/jean/tmp/minus.scm:
9:19 2 (_)
In oop/goops.scm:
1567:11 1 (cache-miss 0 #<<Foo> 7f56944e70b0>)
1585:2 0 (_ _ _)
oop/goops.scm:1585:2: No applicable method for #<<generic> - (1)> in call (- 0
#<<Foo> 7f56944e70b0>)
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
reply other threads:[~2023-07-07 12:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6f7bb96b48e6a80287b9c2f827605b4c3c5bd17b.camel@abou-samra.fr \
--to=jean@abou-samra.fr \
--cc=64508@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).