]> gitweb.factorcode.org Git - factor.git/commitdiff
combinators: call( now throws an error if a quotation that was declared as never...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 6 Apr 2010 20:42:30 +0000 (16:42 -0400)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 6 Apr 2010 20:42:30 +0000 (16:42 -0400)
core/combinators/combinators-tests.factor
core/combinators/combinators.factor

index b239b1eac9a2ab28ee034d0b8ec2889a8ab297f0..1e7a61daaaca52bbd725eaa88f4ea2becb20563d 100644 (file)
@@ -35,6 +35,24 @@ IN: combinators.tests
 [ 7 ] [ 1 3 [ 2 * ] [ + ] compose compile-call(-test-1 ] unit-test
 [ 4 ] [ 1 3 [ { + } [ ] like call ] compile-call(-test-1 ] unit-test
 
+[ [ ] call( -- * ) ] must-fail
+
+: compile-call(-test-2 ( -- ) [ ] call( -- * ) ;
+
+[ compile-call(-test-2 ] [ wrong-values? ] must-fail-with
+
+: compile-call(-test-3 ( quot -- ) call( -- * ) ;
+
+[ [ ] compile-call(-test-3 ] [ wrong-values? ] must-fail-with
+
+: compile-execute(-test-3 ( a -- ) \ . execute( value -- * ) ;
+
+[ 10 compile-execute(-test-3 ] [ wrong-values? ] must-fail-with
+
+: compile-execute(-test-4 ( a word -- ) execute( value -- * ) ;
+
+[ 10 \ . compile-execute(-test-4 ] [ wrong-values? ] must-fail-with
+
 ! Compiled
 : cond-test-1 ( obj -- str )
     {
index 7ef2ed5f9fd9d7dabc0632d81147b1365994dadc..7ef8ef68eae3ca2346801556dd9d7fcedd5bfa2e 100644 (file)
@@ -30,11 +30,12 @@ SLOT: out
 : call-effect ( quot effect -- )
     ! Don't use fancy combinators here, since this word always
     ! runs unoptimized
-    [ datastack ] 2dip
     2dup [
-        [ dip ] dip
-        dup in>> length swap out>> length
-        check-datastack
+        [ [ datastack ] dip dip ] dip
+        dup terminated?>> [ 2drop f ] [
+            dup in>> length swap out>> length
+            check-datastack
+        ] if
     ] 2dip rot
     [ 2drop ] [ wrong-values ] if ;