GNU bug report logs - #56751
Protocol of parent record type is ignored

Previous Next

Package: guile;

Reported by: Maxime Devos <maximedevos <at> telenet.be>

Date: Sun, 24 Jul 2022 20:58:02 UTC

Severity: normal

To reply to this bug, email your comments to 56751 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#56751; Package guile. (Sun, 24 Jul 2022 20:58:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maxime Devos <maximedevos <at> telenet.be>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sun, 24 Jul 2022 20:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: bug-guile <at> gnu.org
Subject: Protocol of parent record type is ignored
Date: Sun, 24 Jul 2022 22:56:58 +0200
[Message part 1 (text/plain, inline)]
(import (rnrs records syntactic)
        (rnrs base))

(define-record-type
    (#{I have one field, but no need to set it, I'll do it myself}# 
make-1 type-1?)
  (fields (immutable #{field with a fixed value}# #{get first field 
value}#))
  (protocol
   (lambda (%make)
     (lambda ()
       (#;(%make) ;; XXX unlike what is documented, this needs to be:
    %make
    ;; instead.  Bug in inmplementation or documentation?  Not the issue
    ;; I wanted to note though.
    "some value")))))

(assert (string=? (#{get first field value}# (make-1)) "some value")) ; ok

(define-record-type (#{the subtype}# make-2 type-2?)
  (parent #{I have one field, but no need to set it, I'll do it myself}#))

;;  The problem:
;;
;; Guile seems to have forgotten that the protocol of the supertype,
;; and hence asks for a value for the argument even though the protocol
;; of the original record type normally would give it a value.
;; (Ok, this is interpretation for the symptoms, I haven't yet tested 
this against
;; the source code).
;;
;; This manifests as make-2 havng arity 1 though it should have arity 1:
#;
(assert (equal? (#{get first field value}# (make-2) "some value"))) ;; 
--> wrong number of arguments to #<procedure ...>

;; We can due to the bug also break the abstraction: (see assert failure)
(assert (equal? (#{get first field value}# (make-2 
'break-the-abstraction)) "some value")) ;; --> wrong number of arguments 
to #<procedure ...>

;; Note: if I explicitly write the protocol for the subtype, then all 
the problems disappear
;; (work-around).  For an example in the wild, see the supertype 
<lost-and-found> at
;; 
<https://git.gnunet.org/gnunet-scheme.git/tree/gnu/gnunet/concurrency/lost-and-found.scm>
;; and the subtype at 
<https://git.gnunet.org/gnunet-scheme.git/tree/gnu/gnunet/dht/client.scm#n583>
;; (Not the best example, as I give the new fields default values as 
well, but you get the idea.)

[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

This bug report was last modified 1 year and 274 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.