From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 07 08:56:24 2023 Received: (at submit) by debbugs.gnu.org; 7 Jul 2023 12:56:24 +0000 Received: from localhost ([127.0.0.1]:42749 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHl0Z-0003kA-JR for submit@debbugs.gnu.org; Fri, 07 Jul 2023 08:56:24 -0400 Received: from lists.gnu.org ([209.51.188.17]:39178) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qHl0X-0003k2-Em for submit@debbugs.gnu.org; Fri, 07 Jul 2023 08:56:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qHl0X-0006Pu-8P for bug-guile@gnu.org; Fri, 07 Jul 2023 08:56:21 -0400 Received: from mout.kundenserver.de ([217.72.192.73]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qHl0V-0007G8-5u for bug-guile@gnu.org; Fri, 07 Jul 2023 08:56:20 -0400 Received: from [10.102.140.73] ([193.190.193.4]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.184]) with ESMTPSA (Nemesis) id 1MdNHa-1pihIu1S4W-00ZQB2 for ; Fri, 07 Jul 2023 14:56:16 +0200 Message-ID: <6f7bb96b48e6a80287b9c2f827605b4c3c5bd17b.camel@abou-samra.fr> Subject: Optimization of "-" function is incorrect in presence of GOOPS overloading From: Jean Abou Samra To: bug-guile@gnu.org Date: Fri, 07 Jul 2023 14:56:15 +0200 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-/uCFF9OG9+W/ZLCTFSrm" User-Agent: Evolution 3.48.3 (3.48.3-1.fc38) MIME-Version: 1.0 X-Provags-ID: V03:K1:OYu8MtAUsk8MOCEJqxx3QWDiVfr5KOcLhbaJOgHR85zRczvOMcr 3xugzM/pF2gwPZV3Z8RgYJap64IYL4cORclEXlPRiCZ9YIeOQPW3h1A3ocAHqKlm4mCcCJu u8VSZSQpiPwX4oa8AsZgT+OMhacBbNEutqVCiws+J8N+RB+I/Z4199L1AwMLxsqIAFEVlg8 7yYlzInGK6QO5M9nK0ItA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:lONT9nCFt5w=;9xpFy+kwe3hHsyBRYxHXguubg2G rJRZILlvmwWOqEmdAvtcwMhlVMQ9cuH68I3ydRGddycNiyykDliUK+yOCjlhH8v9iK9rW5//U dGKVXMo8znCrIqpGuQ/AQHd4CoUrqpSgQuJZAwpkypF3I/nmVXYA9d1knuI+/HHLF2kT1uw0g yz85eqrNQwTEdAzTce/dbw1pfyMbkh7iwHpT69IPKRYl2e1Ng5mKik2zZfYhjykY4yFNcS1wf Fg16whbcP+2V8+ydwtFghyBFNkieNpYR8bxhjcuKhQmxncrOjU8ERT8j/Z2GwqIkKS1BJDraj H2TdGIxv5iicKJxnAxBEUounrA3hDUM6l6lgMxQHr7NZijq9TJSG4MWRVrDsTUUJqV5TXY+4q pqOMG2V8tAQ0Z61zOl6Qpo2iEEL+kjPfGvOn19XN+szpqyDsCpzoiOZ/9CU+ExxPU09oBZ31H 8y+6yf3fzPXwgd7ZaDGp7WYrAnnxRVVE/bW8uu2EObjZrw511HX7rF3Ofdp55WUIrq1plQz/C qdrx8PsAup+81BUVovn5CabBZ8AbA7CRqShL867/Et6p0dlyyonZjU3MpDd+lwlWIyPdTqrnk bTWf4NyvwjXRBEKaqOtAlwWqcdKrKG3Zlkvvj5Ql+MIW6A3qmoXHikVfuk5wXXbXomYdRvQGM kGNkyaj6AbL/AgVns122BUPlyivHXy8rOs9CMJbMlA== Received-SPF: pass client-ip=217.72.192.73; envelope-from=jean@abou-samra.fr; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-/uCFF9OG9+W/ZLCTFSrm Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 =3D (- 0 x) The longer version: $ cat minus.scm=20 (use-modules (oop goops)) (define-class () (bar #:init-keyword #:bar)) (define-method (- (x )) (make #:bar (- (slot-ref x 'bar)))) (display (slot-ref (- (make #:bar 5)) 'bar)) (newline) $ guile3.0 --no-auto-compile minus.scm=20 -5 $ guile3.0 minus.scm=20 ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=3D0 ;;; 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 #) In ice-9/boot-9.scm: 724:2 6 (call-with-prompt _ _ #) In ice-9/eval.scm: 619:8 5 (_ #(#(#))) 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 #< 7f56944e70b0>) 1585:2 0 (_ _ _) oop/goops.scm:1585:2: No applicable method for #< - (1)> in call (= - 0 #< 7f56944e70b0>) --=-/uCFF9OG9+W/ZLCTFSrm Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSZ7TKxnKGyBvBjzBmj8PYLiTOX/gUCZKgLbwAKCRCj8PYLiTOX /kA/AP97eMsxzCb4Dq1X6Ph1AfDTZ6j6nKDVF3HI5VQIvrrlPwEAqwYEnPFWCtkd NWMCYj1t4pKR9Q2dUyZRLcea789/Egk= =JJRk -----END PGP SIGNATURE----- --=-/uCFF9OG9+W/ZLCTFSrm--