# HG changeset patch # User Steve Losh # Date 1468101062 0 # Node ID 07e1d5f315f5ff2b1118a65a760893cbf6a430bc # Parent 92c590f78133b5b89863d9f728236f6a50cac4ee Fix constant unification How did I not notice this til now? Jesus. This is a mistake in the book that the erratum pointed out and I read but somehow just ignored because I'm an idiot. diff -r 92c590f78133 -r 07e1d5f315f5 src/circle.lisp --- a/src/circle.lisp Sat Jul 09 21:03:01 2016 +0000 +++ b/src/circle.lisp Sat Jul 09 21:51:02 2016 +0000 @@ -45,7 +45,7 @@ (defparameter *circle-sentinel* 'circle-sentinel) -(declaim (inline circle-prev circle-value circle-next)) +(declaim (inline circle-prev circle-value circle-next make-circle)) (defstruct circle prev value next) diff -r 92c590f78133 -r 07e1d5f315f5 src/wam/vm.lisp --- a/src/wam/vm.lisp Sat Jul 09 21:03:01 2016 +0000 +++ b/src/wam/vm.lisp Sat Jul 09 21:51:02 2016 +0000 @@ -662,13 +662,15 @@ (define-instruction %set-constant ((wam wam) (constant functor-index)) - (wam-heap-push! wam (make-cell-constant constant))) + (wam-heap-push! wam (make-cell-constant constant)) + (incf (wam-subterm wam))) (define-instruction %unify-constant ((wam wam) (constant functor-index)) (ecase (wam-mode wam) (:read (%%match-constant wam constant (wam-subterm wam))) - (:write (wam-heap-push! wam (make-cell-constant constant))))) + (:write (wam-heap-push! wam (make-cell-constant constant)))) + (incf (wam-subterm wam))) ;;;; Running diff -r 92c590f78133 -r 07e1d5f315f5 test/wam.lisp --- a/test/wam.lisp Sat Jul 09 21:03:01 2016 +0000 +++ b/test/wam.lisp Sat Jul 09 21:51:02 2016 +0000 @@ -435,3 +435,11 @@ ((c) empty) ((d) fail) (dogs empty)))) + +(test nested-constants + (with-fresh-database + (push-logic-frame-with + (fact (foo (s a b c)))) + (should-return + ((foo (s ?x ?y ?z)) + (?x a ?y b ?z c)))))