bug#56751: Protocol of parent record type is ignored
Maxime Devos <[email protected]>
| Newsgroups | gmane.lisp.guile.bugs |
|---|---|
| Message-ID | <[email protected]> |
(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, 912 B)
-----BEGIN PGP PUBLIC KEY BLOCK----- xjMEX4ch6BYJKwYBBAHaRw8BAQdANPb/d6MrGnGi5HyvODCkBUJPRjiFQcRU5V+m xvMaAa/NL01heGltZSBEZXZvcyA8bWF4aW1lLmRldm9zQHN0dWRlbnQua3VsZXV2 ZW4uYmU+wpAEExYIADgWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCX4ch6AIbAwUL CQgHAwUVCgkICwUWAgMBAAIeAQIXgAAKCRBJ4+4iGRcl7japAQC3opZ2KGWzWmRc /gIWSu0AAcfMwyinFEEPa/QhUt2CogD/e2RdF4CYAgaRHJJmZ9WU7piKbLZ7llB4 LzgezVDHggzNJU1heGltZSBEZXZvcyA8bWF4aW1lZGV2b3NAdGVsZW5ldC5iZT7C kAQTFggAOBYhBMHzPuIMUo/bfdcBH0nj7iIZFyXuBQJf56ycAhsDBQsJCAcDBRUK CQgLBRYCAwEAAh4BAheAAAoJEEnj7iIZFyXujpQBAKV1SwDDl4f24rXciDlB9L8W ycZt30CgbewMSRQk4mvbAP9dFMbVVixYBd6C8cfhR+NsOBGiOJnQABlUmgNuqGFJ Dc44BF+HIegSCisGAQQBl1UBBQEBB0BOlzIWiJzgobMF6/cqwLaLk7jIcFSZ++c0 k9cCNT6YXwMBCAfCeAQYFggAIBYhBMHzPuIMUo/bfdcBH0nj7iIZFyXuBQJfhyHo AhsMAAoJEEnj7iIZFyXuMr0BAJc8cl5PGvVmVuSQVKjleNl4DK1/XAaPAYPe34AE fZJPAP9IqLCQhH/FeJanHqBP8gNdGNI2qn8RnnLVfRJgUjZ1BA== =OVqp -----END PGP PUBLIC KEY BLOCK-----
OpenPGP_signature
(application/pgp-signature, 236 B) - not displayed