From 274c4b655b249a637e9a707db71d839c36829689 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 6 Apr 2016 06:31:00 -0700 Subject: Diagnose bad supertype in defstruct. * share/txr/stdlib/struct.tl (defstruct): If super isn't nil, it must name an existing struct type, or an exception is thrown. Previously, a nonexistent struct was silently treated as if nil had been specified. --- share/txr/stdlib/struct.tl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'share') diff --git a/share/txr/stdlib/struct.tl b/share/txr/stdlib/struct.tl index ee4bfd18..2f1692f5 100644 --- a/share/txr/stdlib/struct.tl +++ b/share/txr/stdlib/struct.tl @@ -112,7 +112,12 @@ ^(:instance ,name nil)) (name ^(:instance ,name nil))))) - (super-type (find-struct-type super)) + (super-type (if super + (or (find-struct-type super) + (throwf 'eval-error + "~a: inheritance base ~s \ + \ does not name a struct type" + 'defstruct super)))) (stat-si-forms [keep-if (op member @1 '(:static :function)) slot-init-forms car]) (pruned-si-forms (sys:prune-nil-inits stat-si-forms super-type)) -- cgit v1.2.3