src/builtin.lisp: Don't assume we have an initializer if there are initargs.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 3 Aug 2019 14:55:03 +0000 (15:55 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 3 Aug 2019 15:46:22 +0000 (16:46 +0100)
This caused an ugly crash with the text

class Foo: SodObject {
  [initarg = x] int x;
}

src/builtin.lisp

index 776d3a1..08ad5f0 100644 (file)
@@ -422,12 +422,12 @@ static const SodClass *const ~A__cpl[] = {
                (when (or init initargs)
                  (focus-this-class)
                  (let* ((slot-type (sod-slot-type dslot))
-                        (slot-default (sod-initializer-value init))
                         (target (format nil "~A.~A"
                                         isl (sod-slot-name dslot)))
-                        (initinst (set-from-initializer target
-                                                        slot-type
-                                                        slot-default)))
+                        (initinst (and init
+                                       (set-from-initializer
+                                        target slot-type
+                                        (sod-initializer-value init)))))
 
                    ;; If there are applicable initialization arguments,
                    ;; check to see whether they were supplied.