unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#36691: GOOPS: accessor breaks inherited slots with getters
@ 2019-07-16 14:21 Thompson, David
  0 siblings, 0 replies; only message in thread
From: Thompson, David @ 2019-07-16 14:21 UTC (permalink / raw)
  To: 36691

Hi,

When a subclass inherits a slot with a getter, but a previously
defined class creates an accessor with the same name, the inherited
getter is seemingly ignored and an error is thrown when attempting to
use the getter on an instance of the subclass.  It's hard to explain
in a clear way, so here's a minimal example that demonstrates the
problem:

    (use-modules (oop goops))

    (define-class <cat> ()
      (name #:getter name #:init-keyword #:name))

    (define-class <boat> ()
      (name #:accessor name #:init-keyword #:name))

    (define-class <leopard> (<cat>))

    (display (name (make <cat> #:name "Mittens")))
    (newline)
    (display (name (make <boat> #:name "Boaty McBoatface")))
    (newline)
    (display (name (make <leopard> #:name "Spot")))
    (newline)

This program outputs "Mittens" and "Boaty McBoatface" then prints a
backtrace when it should print "Spot":

    Backtrace:
               7 (apply-smob/1 #<catch-closure 5556814626c0>)
    In ice-9/boot-9.scm:
        702:2  6 (call-with-prompt ("prompt") #<procedure 55568147c920 …> …)
    In ice-9/eval.scm:
        619:8  5 (_ #(#(#<directory (guile-user) 555681529750>)))
    In ice-9/boot-9.scm:
       2296:4  4 (save-module-excursion #<procedure 55568153acc0 at ice-…>)
      3816:12  3 (_)
    In /home/dthompson/Code/starling/examples/tetra/test.scm:
         15:9  2 (_)
    In oop/goops.scm:
       1460:4  1 (cache-miss #<<leopard> 5556815fd730>)
       1585:2  0 (goops-error _ . _)

    oop/goops.scm:1585:2: In procedure goops-error:
    No applicable method for #<<accessor> name (2)> in call (name
#<<leopard> 5556815fd730>)

I am using Guile 2.9.2 on GNU/Linux.

- Dave





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-07-16 14:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-16 14:21 bug#36691: GOOPS: accessor breaks inherited slots with getters Thompson, David

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).