From: Vivien Kraus via "Bug reports for GUILE, GNU's Ubiquitous Extension Language" <bug-guile@gnu.org>
To: 50719@debbugs.gnu.org
Subject: bug#50719: Cannot add a no-applicable-method implementation for a generic with no method
Date: Tue, 21 Sep 2021 11:42:51 +0200 [thread overview]
Message-ID: <adfdb26ac3bdd85c61ecf2dddfbdb1f67bfec4db.camel@planete-kraus.eu> (raw)
[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]
Dear guile,
The following program should just return 'foo, but it enters an
infinite loop:
(use-modules (oop goops))
(define-class <my-generic> (<generic>))
(define-method (no-method (generic <my-generic>) args)
'foo)
(define-method (no-applicable-method (generic <my-generic>) args)
'foo)
(define hello
(make <my-generic>
#:name 'hello))
(hello)
I don’t know GOOPS enough to understand what happens, but when I
slightly change the last line:
(use-modules (oop goops))
(define-class <my-generic> (<generic>))
(define-method (no-method (generic <my-generic>) args)
'foo)
(define-method (no-applicable-method (generic <my-generic>) args)
'foo)
(define hello
(make <my-generic>
#:name 'hello))
(apply-generic hello '())
Now it returns 'foo, as expected. So my guess is that the infinite
loops happens during the memoization phase. More specifically, the no-
applicable-method is called over and over again.
Please find a failing test case attached.
Best regards,
Vivien
[-- Attachment #2: 0001-goops-cannot-override-no-applicable-method-for-a-gen.patch --]
[-- Type: text/x-patch, Size: 1542 bytes --]
From 435d4d7569a25dda05489c3eda3086e0dbf531af Mon Sep 17 00:00:00 2001
From: Vivien Kraus <vivien@planete-kraus.eu>
Date: Tue, 21 Sep 2021 11:40:43 +0200
Subject: [PATCH] goops: cannot override no-applicable-method for a generic
that has no methods
---
test-suite/tests/goops.test | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/test-suite/tests/goops.test b/test-suite/tests/goops.test
index b06ba98b2..626eeaacd 100644
--- a/test-suite/tests/goops.test
+++ b/test-suite/tests/goops.test
@@ -761,3 +761,22 @@
#:metaclass <redefinable-meta>)))
(pass-if-equal 123 (get-the-bar (make <foo>)))
(pass-if-equal 123 (get-the-bar (make <redefinable-foo>))))))
+
+(with-test-prefix "Can override no-applicable-method in a generic without methods"
+ (let ((patience-no-method 10)
+ (patience-no-applicable-method 10))
+ (define-class <my-generic> (<generic>))
+ (define-method (no-method (generic <my-generic>) args)
+ (when (= patience-no-method 0)
+ (error "Infinite loop detected in no-method"))
+ (set! patience-no-method (- patience-no-method 1))
+ 'foo)
+ (define-method (no-applicable-method (generic <my-generic>) args)
+ (when (= patience-no-applicable-method 0)
+ (error "Infinite loop detected in no-applicable-method"))
+ (set! patience-no-applicable-method (- patience-no-applicable-method 1))
+ 'foo)
+ (define hello
+ (make <my-generic>
+ #:name 'hello))
+ (pass-if-equal (hello) 'foo)))
--
2.33.0
reply other threads:[~2021-09-21 9:42 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=adfdb26ac3bdd85c61ecf2dddfbdb1f67bfec4db.camel@planete-kraus.eu \
--to=bug-guile@gnu.org \
--cc=50719@debbugs.gnu.org \
--cc=vivien@planete-kraus.eu \
/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).