From: Mark H Weaver <mhw@netris.org>
To: guile-devel@gnu.org
Subject: [PATCH] Fix GOOPS method compilation bug when no next-method exists
Date: Sat, 29 Jan 2011 22:21:30 -0500 [thread overview]
Message-ID: <871v3v2i11.fsf@yeeloong.netris.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1418 bytes --]
I was playing with GOOPS and noticed this bug:
> scheme@(guile-user)> (use-modules (oop goops))
> scheme@(guile-user)> (define-method (+ (x <list>) (y <list>)) (next-method))
> scheme@(guile-user)> (+ '() '())
> oop/goops/compile.scm:48:35: In procedure car:
> oop/goops/compile.scm:48:35: Wrong type argument in position 1 (expecting pair): ()
>
> Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
> scheme@(guile-user) [1]> ,bt
>
> In standard input:
> 8:0 4 (#<procedure a879a0 at standard input:8:0 ()>)
> In oop/goops/dispatch.scm:
> 231:9 3 (cache-miss #<<generic> + (1)> (() ()))
> 246:4 2 (memoize-effective-method! #<<generic> + (1)> (() ()) (#))
> In oop/goops/compile.scm:
> 54:13 1 (compute-cmethod (#<<method> (<list> <list>) afc640>) (…))
> 48:34 0 (compute-cmethod () (#<<class> <null> befd20> #<<clas…>))
With the attached patch applied, here's what happens instead:
> scheme@(guile-user)> (define-method (+ (x <list>) (y <list>)) (next-method))
> scheme@(guile-user)> (+ '() '())
> ERROR: In procedure scm-error:
> ERROR: No next method when calling #<<generic> + (1)>
> with arguments (() ())
>
> Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
> scheme@(guile-user) [1]> ,q
I confess I don't know much about GOOPS, but I think the fix is pretty
obvious.
Best,
Mark
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Fix GOOPS method compilation bug when no next-method exists --]
[-- Type: text/x-diff, Size: 1062 bytes --]
From 2b838f70704ae0bebc3c00c0114505c80967f51f Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
Date: Sat, 29 Jan 2011 22:07:49 -0500
Subject: [PATCH] Fix GOOPS method compilation bug when no next-method exists
* module/oop/goops/compile.scm (compute-cmethod): Fix a bug
that caused the method compiler to barf while compiling a
method that calls (next-method), if there is no applicable
next method.
---
module/oop/goops/compile.scm | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/module/oop/goops/compile.scm b/module/oop/goops/compile.scm
index db1a160..ace89b4 100644
--- a/module/oop/goops/compile.scm
+++ b/module/oop/goops/compile.scm
@@ -48,7 +48,7 @@
(let ((make-procedure (slot-ref (car methods) 'make-procedure)))
(if make-procedure
(make-procedure
- (if (null? methods)
+ (if (null? (cdr methods))
(lambda args
(no-next-method (method-generic-function (car methods)) args))
(compute-cmethod (cdr methods) types)))
--
1.5.6.5
next reply other threads:[~2011-01-30 3:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-30 3:21 Mark H Weaver [this message]
2011-01-30 12:30 ` [PATCH] Fix GOOPS method compilation bug when no next-method exists Andy Wingo
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=871v3v2i11.fsf@yeeloong.netris.org \
--to=mhw@netris.org \
--cc=guile-devel@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).