hyln9 / ikarus

Optimizing incremental native-code compiler for R6RS scheme. This is a forked repository.
https://launchpad.net/ikarus
Other
5 stars 0 forks source link

record-rtd exception message giving away to much information #261

Open hyln9 opened 10 years ago

hyln9 commented 10 years ago

Using record-rtd on an opaque record gives the following exception message:

juergen@Nix:~$ ikarus Ikarus Scheme version 0.0.4-rc1+, 64-bit (revision 1854, build 2009-09-08) Copyright (c) 2006-2009 Abdulaziz Ghuloum

(define-record-type foo (opaque #t)) (define bar (make-foo)) (record-rtd bar) Unhandled exception Condition components:

  1. &assertion
  2. &who: record-rtd
  3. &message: "record is opaque"
  4. &irritants: ()

By intercepting this exception it's possible to create a new record predicate:

(define (record2? r) (guard (con (else (string=? "record is opaque" (condition-message con)))) (or (record? r) (record-rtd r)))) (record? bar)

f

(record2? bar)

t

I think it shouldn't be possible to do this. It should instead raise the same exception as for non-record objects:

(record-rtd 123) Unhandled exception Condition components:

  1. &assertion
  2. &who: record-rtd
  3. &message: "not a record"
  4. &irritants: (123)

Launchpad Details: #LP427859 Juergen Haase - 2009-09-11 09:06:32 -0400

hyln9 commented 10 years ago

On Sep 11, 2009, at 4:06 PM, Juergen Haase wrote:

Public bug reported:

Using record-rtd on an opaque record gives the following exception message:

juergen@Nix:~$ ikarus Ikarus Scheme version 0.0.4-rc1+, 64-bit (revision 1854, build
2009-09-08) Copyright (c) 2006-2009 Abdulaziz Ghuloum

(define-record-type foo (opaque #t)) (define bar (make-foo)) (record-rtd bar) Unhandled exception Condition components:

  1. &assertion
  2. &who: record-rtd
  3. &message: "record is opaque"
  4. &irritants: ()

Yes, but messages are informational for you only: they cannot be used
reliably to deduce semantics. Consider that I might change the
message tomorrow to make it something else, like "record rtd is
inaccessible" or "Rekord ist undurchsichtig" or "εγγραφή
νεκρός", right? Consider that you (or someone else) might be
running your code under a different implementation. In any way, you
cannot rely on this as a source of information, so, changing it does
not add or subtract anything. [also, the message "not a record" is
technically false since it is a record, the record system knows it
is a record, and it's just lying. "record is opaque" is technically
the correct message for both errors.]

(record? is also a liar as per R6RS's specification: it should've been
called nonopaque-record? or transparent-record? or something like it.)

Aziz,,,

Launchpad Details: #LPC Abdulaziz Ghuloum - 2009-09-12 15:52:12 -0400

hyln9 commented 10 years ago

Ah yes, I understand. Thanks for setting me straight on this one.

Juergen

Launchpad Details: #LPC Juergen Haase - 2009-09-12 20:00:18 -0400