]> gitweb.factorcode.org Git - factor.git/commitdiff
Throw typed errors instead of strings for calling/executing non-callables
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 12 Aug 2009 03:40:29 +0000 (22:40 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 12 Aug 2009 03:40:29 +0000 (22:40 -0500)
basis/stack-checker/backend/backend.factor
basis/stack-checker/known-words/known-words.factor

index 338b052316146c9fbd19d2b44fd8deb0fc2efd08..5411c885ad7165f0a7a44ea55e2c879df6658c79 100755 (executable)
@@ -5,7 +5,7 @@ parser sequences strings vectors words quotations effects classes
 continuations assocs combinators compiler.errors accessors math.order
 definitions sets hints macros stack-checker.state
 stack-checker.visitor stack-checker.errors stack-checker.values
-stack-checker.recursive-state ;
+stack-checker.recursive-state summary ;
 IN: stack-checker.backend
 
 : push-d ( obj -- ) meta-d push ;
@@ -98,8 +98,10 @@ M: object apply-object push-literal ;
 : time-bomb ( error -- )
     '[ _ throw ] infer-quot-here ;
 
-: bad-call ( -- )
-    "call must be given a callable" time-bomb ;
+ERROR: bad-call obj ;
+
+M: bad-call summary
+    drop "call must be given a callable" ;
 
 : infer-literal-quot ( literal -- )
     dup recursive-quotation? [
@@ -110,7 +112,7 @@ M: object apply-object push-literal ;
             [ [ recursion>> ] keep add-local-quotation ]
             bi infer-quot
         ] [
-            drop bad-call
+            value>> \ bad-call boa time-bomb
         ] if
     ] if ;
 
index 6959e3245224ce3ccc094c0572ff0b80a72e31bb..59aeb97d82c84fa1796e7f4fc7c466e166ece24f 100644 (file)
@@ -134,13 +134,17 @@ M: object infer-call*
 
 \ compose [ infer-compose ] "special" set-word-prop
 
+ERROR: bad-executable obj ;
+
+M: bad-executable summary
+    drop "execute must be given a word" ;
+
 : infer-execute ( -- )
     pop-literal nip
     dup word? [
         apply-object
     ] [
-        drop
-        "execute must be given a word" time-bomb
+        \ bad-executable boa time-bomb
     ] if ;
 
 \ execute [ infer-execute ] "special" set-word-prop