diff --git a/basis/xml/interpolate/interpolate-tests.factor b/basis/xml/interpolate/interpolate-tests.factor
index 621480abb9..3067254a60 100644
--- a/basis/xml/interpolate/interpolate-tests.factor
+++ b/basis/xml/interpolate/interpolate-tests.factor
@@ -53,3 +53,6 @@ IN: xml.interpolate.tests
[ "3" ] [ 3 [XML <-> XML] xml-chunk>string ] unit-test
[ "" ] [ f [XML <-> XML] xml-chunk>string ] unit-test
+
+\ parse-def must-infer
+[ "" interpolate-chunk ] must-infer
diff --git a/basis/xml/interpolate/interpolate.factor b/basis/xml/interpolate/interpolate.factor
index 9e39ba8fdc..0b3bb15456 100644
--- a/basis/xml/interpolate/interpolate.factor
+++ b/basis/xml/interpolate/interpolate.factor
@@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license.
USING: xml xml.state kernel sequences fry assocs xml.data
accessors strings make multiline parser namespaces macros
-sequences.deep generalizations locals words combinators
+sequences.deep generalizations words combinators
math present arrays ;
IN: xml.interpolate
@@ -48,23 +48,23 @@ M: interpolated interpolate-item
: interpolate-xml-doc ( table xml -- xml )
(clone) [ interpolate-tag ] change-body ;
-GENERIC# (each-interpolated) 1 ( item quot -- ) inline
-M: interpolated (each-interpolated) call ;
-M: tag (each-interpolated)
- swap attrs>> values
- [ interpolated? ] filter
- swap each ;
-M: xml (each-interpolated)
- [ body>> ] dip (each-interpolated) ;
-M: object (each-interpolated) 2drop ;
+: (each-interpolated) ( item quot: ( interpolated -- ) -- )
+ {
+ { [ over interpolated? ] [ call ] }
+ { [ over tag? ] [
+ [ attrs>> values [ interpolated? ] filter ] dip each
+ ] }
+ { [ over xml? ] [ [ body>> ] dip (each-interpolated) ] }
+ [ 2drop ]
+ } cond ; inline recursive
: each-interpolated ( xml quot -- )
'[ _ (each-interpolated) ] deep-each ; inline
-:: number<-> ( doc -- doc )
- 0 :> n! doc [
- dup var>> [ n >>var n 1+ n! ] unless drop
- ] each-interpolated doc ;
+: number<-> ( doc -- dup )
+ 0 over [
+ dup var>> [ over >>var [ 1+ ] dip ] unless drop
+ ] each-interpolated drop ;
MACRO: interpolate-xml ( string -- doc )
string>doc number<-> '[ _ interpolate-xml-doc ] ;
diff --git a/basis/xml/tests/test.factor b/basis/xml/tests/test.factor
index bed729e300..e3a7fdbc7a 100644
--- a/basis/xml/tests/test.factor
+++ b/basis/xml/tests/test.factor
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2006 Daniel Ehrenberg
+! Copyright (C) 2005, 2009 Daniel Ehrenberg
! See http://factorcode.org/license.txt for BSD license.
IN: xml.tests
USING: kernel xml tools.test io namespaces make sequences