Struct 结构布局:can';I don’我不需要构造一个构造函数来设置我需要的字段

Struct 结构布局:can';I don’我不需要构造一个构造函数来设置我需要的字段,struct,lisp,common-lisp,Struct,Lisp,Common Lisp,下面的代码“已编译”,但功能不正常: (defstruct (image-info (:conc-name img-) (:constructor %make-img-info (&key file)) (:print-function print-img-info)) (file nil :type string) (gd-image nil :type (or cl-gd::image null))

下面的代码“已编译”,但功能不正常:

(defstruct (image-info
             (:conc-name img-)
             (:constructor %make-img-info (&key file))
             (:print-function print-img-info))
  (file nil :type string)
  (gd-image nil :type (or cl-gd::image null))
  (size '(0 . 0) :type cons)
  (position '(0 . 0) :type cons))

(defun print-img-info (info stream level)
  (declare (ignore level))
  (let ((size (img-size info))
        (pos (img-position info)))
    (format stream "~s[width: ~d, height: ~d, x: ~d, y: ~d]"
            (img-file info)
            (car size) (cdr size) (car pos) (cdr pos))))

(defun make-img-info (path)
  (let ((image (cl-gd:create-image-from-file path))
        (info (%make-img-info :file path))) ; <--- problem here
    (setf (img-gd-image info) image
          (img-size info)
          (cons (cl-gd:image-width image)
                (cl-gd:image-height image))) info))
但是当我试图编译
make img info
时,我得到了以下结果:

  note: deleting unreachable code
  warning: 
    Derived type of PATH is
      (VALUES CL-GD::IMAGE &OPTIONAL),
    conflicting with its asserted type
      STRING.

我正在向这个函数传递正确的参数(字符串),但它仍然无法调用它,因为它“相信”它必须是
cl gd:image
。我怀疑问题在于布局是按字母顺序排列的,
gd image
出现在列表中的
file
之前。。。但我该如何解决这个问题呢?我真的不想重命名该字段?

现在我认为这是一个与SLIME和SBCL在编译结构时没有很好地配合有关的小故障。我无法始终如一地重现这种行为,但它也会时不时地发生在其他结构上,因此有时我需要杀死SLIME和SWANK,重新启动SBCL并重新编译,因为只重新编译结构的相关部分将不起作用


我不会删除这个问题,因为如果有人遇到类似的行为,也许重新启动Lisp会有所帮助,因此这一体验会很有用。

在sbcl 1.1.2中编译时,我没有发现任何错误。我没有在引擎盖下安装GD库。
  note: deleting unreachable code
  warning: 
    Derived type of PATH is
      (VALUES CL-GD::IMAGE &OPTIONAL),
    conflicting with its asserted type
      STRING.