1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

goops: Fix 'instance?' to work on objects that aren't structs.

Fixes <https://bugs.gnu.org/31606>
Reported by Tommi Höynälänmaa <tommi.hoynalanmaa@gmail.com>

* module/oop/goops.scm (instance?): Check that OBJ is a struct
before applying 'struct-vtable' to it.
This commit is contained in:
Mark H Weaver 2018-05-28 12:19:41 -04:00
parent e1dffd3504
commit ff2adb04cb
No known key found for this signature in database
GPG key ID: 7CEF29847562C516

View file

@ -1,6 +1,7 @@
;;;; goops.scm -- The Guile Object-Oriented Programming System
;;;;
;;;; Copyright (C) 1998-2003,2006,2009-2011,2013-2015 Free Software Foundation, Inc.
;;;; Copyright (C) 1998-2003, 2006, 2009-2011, 2013-2015, 2018
;;;; Free Software Foundation, Inc.
;;;; Copyright (C) 1993-1998 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;;
;;;; This library is free software; you can redistribute it and/or
@ -279,7 +280,8 @@
(class-has-flags? (struct-vtable obj) vtable-flag-goops-slot)))
(define-inlinable (instance? obj)
(class-has-flags? (struct-vtable obj) vtable-flag-goops-class))
(and (struct? obj)
(class-has-flags? (struct-vtable obj) vtable-flag-goops-class)))
(define (class-has-statically-allocated-slots? class)
(class-has-flags? class vtable-flag-goops-static))