Re: "Formally" not a bug, but very annoying.
On Nov 21, 2007 7:24 AM, Marco Antoniotti
<antoniotti.marco@disco.unimib.it> wrote:
> Consider the following file/buffer (this is the personal version on
> an Intel Mac 5.0.1)
>
> =====
> (defstruct foo
> (a nil :type string))
>
> (defun bar (a-foo)
> (null (foo-a a-foo)))
> =====
>
> compile it and then...
>
> CL-USER 1 > (defvar f (make-foo))
> F
>
> CL-USER 2 > f
> #S(FOO :A NIL :B NIL)
>
> CL-USER 3 > (bar f)
> NIL
>
What's more, it seems to be a difference in compiled code:
;;; Session 1
CL-USER 1 > (load "~/foo.lisp")
; Loading text file /Users/tayloj/foo.lisp
#P"/Users/tayloj/foo.lisp"
CL-USER 2 > (defvar f (make-foo))
Error: The value Nil does not satisfy the type specifier String.
1 (continue) Return the value(s) anyway.
2 Return some other values.
3 (abort) Return to level 0.
4 Restart top-level loop.
Type :b for backtrace, :c <option number> to proceed, or :? for other options
CL-USER 3 : 1 >
;;; Session 2
CL-USER 1 > (compile-file "~/foo.lisp" :load t)
;;; Compiling file ~/foo.lisp ...
;;; Safety = 3, Speed = 1, Space = 1, Float = 1, Interruptible = 0
;;; Compilation speed = 1, Debug = 2, Fixnum safety = 3
;;; Source level debugging is on
;;; Source file recording is on
;;; Cross referencing is on
; (Top-Level-Form 1)
; (Subfunction (Defsetf Foo-A) (Defstruct Foo))
; (Subfunction Make-Foo (Defstruct Foo))
; (Subfunction Make-Foo (Defstruct Foo))
; Bar
; (Top-Level-Form 2)
; Loading fasl file /Users/tayloj/foo.nfasl
#P"/Users/tayloj/foo.nfasl"
Nil
Nil
CL-USER 2 > (defvar f (make-foo))
F
CL-USER 3 > f
#S(Foo :A Nil)
and safety was 3. What other settings bear on whether type
discrepancies signal an error?
Now, if the defvar is in the file, (now on foo2.lisp)
;;; Loading...
CL-USER 1 > (load "~/foo2.lisp")
; Loading text file /Users/tayloj/foo2.lisp
Error: The value Nil does not satisfy the type specifier String.
1 (continue) Return the value(s) anyway.
2 Return some other values.
3 Try loading ~/foo2.lisp again.
4 Give up loading ~/foo2.lisp.
5 Try loading another file instead of ~/foo2.lisp.
6 (abort) Return to level 0.
7 Restart top-level loop.
Type :b for backtrace, :c <option number> to proceed, or :? for other options
CL-USER 2 : 1 >
;;; Compile and Loading
CL-USER 1 > (compile-file "~/foo2.lisp" :load t)
;;; Compiling file ~/foo2.lisp ...
;;; Safety = 3, Speed = 1, Space = 1, Float = 1, Interruptible = 0
;;; Compilation speed = 1, Debug = 2, Fixnum safety = 3
;;; Source level debugging is on
;;; Source file recording is on
;;; Cross referencing is on
; (Top-Level-Form 1)
; (Subfunction (Defsetf Foo-A) (Defstruct Foo))
; (Subfunction Make-Foo (Defstruct Foo))
; (Subfunction Make-Foo (Defstruct Foo))
; Bar
;;;*** Warning in (Defvar F): Declared type String and value type Null
are disjoint.
; (Defvar F)
; (Top-Level-Form 2)
; Loading fasl file /Users/tayloj/foo2.nfasl
#P"/Users/tayloj/foo2.nfasl"
(((Defvar F) #<Simple-Warning 201007AF>))
T
CL-USER 2 > f
#S(Foo :A Nil)
There's at least a warning in the compilation.
--
=====================
Joshua Taylor
jtaylor@alum.rpi.edu
"A lot of good things went down one time,
back in the goodle days."
John Hartford