]> gitweb.factorcode.org Git - factor.git/commitdiff
Better error message for call( when quotation has the wrong effect
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 1 Feb 2010 07:50:44 +0000 (20:50 +1300)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 3 Feb 2010 10:11:25 +0000 (23:11 +1300)
basis/compiler/tree/propagation/call-effect/call-effect-tests.factor
basis/compiler/tree/propagation/call-effect/call-effect.factor
basis/debugger/debugger.factor
core/combinators/combinators.factor

index 4b524fd0d48c4a81b9e86edaf6ed262251d492be..03bf43418e6e5552126802c3e5cb32128fe91f4c 100644 (file)
@@ -78,7 +78,7 @@ TUPLE: a-tuple x ;
 
 [ ] [ "IN: compiler.tree.propagation.call-effect.tests USE: math : call(-redefine-test ( a -- c ) 1 + ;" eval( -- ) ] unit-test
 
-[ 1 3 test-quotatation inline-cache-invalidation-test ] [ T{ wrong-values f (( a b -- c )) } = ] must-fail-with
+[ 1 3 test-quotatation inline-cache-invalidation-test ] [ T{ wrong-values f [ call(-redefine-test ] (( a b -- c )) } = ] must-fail-with
 
 ! See if redefining a tuple class bumps effect counter
 TUPLE: my-tuple a b c ;
index 0feeb211a0efca5e8ba710a0721f7fe4086f957c..36883e0456cbd7cda87ccfb269b83a252608cdcb 100644 (file)
@@ -81,17 +81,9 @@ M: quotation cached-effect
     over +unknown+ eq?
     [ 2drop f ] [ [ { effect } declare ] dip effect<= ] if ; inline
 
-: (call-effect-slow>quot) ( in out effect -- quot )
-    [
-        [ [ datastack ] dip dip ] %
-        [ [ , ] bi@ \ check-datastack , ] dip
-        '[ _ wrong-values ] , \ unless ,
-    ] [ ] make ;
-
 : call-effect-slow>quot ( effect -- quot )
-    [ in>> length ] [ out>> length ] [ ] tri
-    [ (call-effect-slow>quot) ] keep add-effect-input
-    [ call-effect-unsafe ] 2curry ;
+    [ \ call-effect def>> curry ] [ add-effect-input ] bi
+    '[ _ _ call-effect-unsafe ] ;
 
 : call-effect-slow ( quot effect -- ) drop call ;
 
@@ -118,7 +110,10 @@ M: quotation cached-effect
     [ '[ _ execute ] ] dip call-effect-slow ; inline
 
 : execute-effect-unsafe? ( word effect -- ? )
-    over optimized? [ [ stack-effect ] dip effect<= ] [ 2drop f ] if ; inline
+    over optimized?
+    [ [ stack-effect { effect } declare ] dip effect<= ]
+    [ 2drop f ]
+    if ; inline
 
 : execute-effect-fast ( word effect inline-cache -- )
     2over execute-effect-unsafe?
index ba90d761cce53981be3b92cad610ae9bfc1a0b36..3c2e6b6dc6f2ad1292485ea8b053b1f0652fee4b 100644 (file)
@@ -339,7 +339,7 @@ M: check-mixin-class summary drop "Not a mixin class" ;
 
 M: not-found-in-roots summary drop "Cannot resolve vocab: path" ;
 
-M: wrong-values summary drop "Quotation called with wrong stack effect" ;
+M: wrong-values summary drop "Quotation's stack effect does not match call site" ;
 
 M: stack-effect-omits-dashes summary drop "Stack effect must contain “--”" ;
 
index 55cc55c3341a315882fe22884ab8f2e29f857a29..ddaa4eac0201f33eef75e15514705fe349e65a54 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2006, 2009 Slava Pestov, Daniel Ehrenberg.
+! Copyright (C) 2006, 2010 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays sequences sequences.private math.private
 kernel kernel.private math assocs quotations vectors
@@ -17,16 +17,21 @@ M: object throw
 
 PRIVATE>
 
-ERROR: wrong-values effect ;
+ERROR: wrong-values quot effect ;
 
 ! We can't USE: effects here so we forward reference slots instead
 SLOT: in
 SLOT: out
 
 : call-effect ( quot effect -- )
-    [ [ datastack ] dip dip ] dip
-    [ in>> length ] [ out>> length ] [ ] tri [ check-datastack ] dip
-    [ wrong-values ] curry unless ;
+    [ datastack ] 2dip
+    [
+        [ dip ] dip
+        [ in>> length ] [ out>> length ] bi
+        check-datastack
+    ]
+    [ [ wrong-values ] 2curry ] 2bi
+    unless ;
 
 : execute-effect ( word effect -- )
     [ [ execute ] curry ] dip call-effect ;