#107: (setf (values (struct-slot struct)) (values 42)) fails -------------------------------------+-------------------------------------- Reporter: mmohamed | Owner: somebody Type: defect | Status: new Priority: major | Milestone: Component: CLOS | Version: Keywords: SETF VALUES STRUCT-SLOT | -------------------------------------+-------------------------------------- ;;; reported by Zach Beane ;;; http://common-lisp.net/pipermail/armedbear- devel/2010-October/001521.html
Here's a file that triggers an ABCL bug:
;;;; abcl-bug.lisp
(defpackage #:abcl-bug (:use #:cl) (:export #:trigger))
(in-package #:abcl-bug)
(defstruct mystruct slot)
(defun trigger () (let ((struct (make-mystruct))) (setf (values (mystruct-slot struct)) (values 42)) struct))
Here's what happens when I run it:
Armed Bear Common Lisp 0.22.0 Java 1.6.0_18 Sun Microsystems Inc. OpenJDK 64-Bit Server VM Low-level initialization completed in 0.445 seconds. Startup completed in 1.688 seconds. Type ":help" for a list of available commands. CL-USER(1): (load (compile-file "abcl-bug")) ; Compiling /tmp/abcl-bug.lisp ... ; (DEFPACKAGE #:ABCL-BUG ...) ; (IN-PACKAGE #:ABCL-BUG) ; (DEFSTRUCT MYSTRUCT ...) ; (DEFUN TRIGGER ...) ; Wrote /tmp/abcl-bug.abcl (0.447 seconds) T CL-USER(2): (abcl-bug:trigger) #<THREAD "interpreter" {1653033E}>: Debugger invoked on condition of type UNDEFINED-FUNCTION The function (SETF SYSTEM:STRUCTURE-REF) is undefined. Restarts: 0: TOP-LEVEL Return to top level. [1] CL-USER(3): :bt 0: (SYSTEM:BACKTRACE) 1: (INVOKE-DEBUGGER #<UNDEFINED-FUNCTION {8FE2509}>) 2: org.armedbear.lisp.Lisp.error(Lisp.java:353) 3: org.armedbear.lisp.Symbol.getSymbolSetfFunctionOrDie(Symbol.java:399) 4: org.armedbear.lisp.abcl_bug_9.execute(abcl-bug.lisp:11) 5: org.armedbear.lisp.LispThread.execute(LispThread.java:552) 6: org.armedbear.lisp.Lisp.evalCall(Lisp.java:514) 7: org.armedbear.lisp.Lisp.eval(Lisp.java:485) [1] CL-USER(4):
I would expect to get a structure back with SLOT set to 42, instead of this error.
This is a strange case (you normally wouldn't use VALUES there) but it comes from some larger real code that sets multiple struct slots from a multiple-value-returning function.