]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix GENERIC# with out of bounds dispatch position
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 13 May 2009 01:47:20 +0000 (20:47 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 13 May 2009 01:47:20 +0000 (20:47 -0500)
core/generic/single/single-tests.factor
core/generic/standard/standard.factor

index e48d404b92a60dd5d43b8cc5ad1804d21571eeb9..61ae4e1ba1090db669be21602f03af8ebc88ac22 100644 (file)
@@ -274,4 +274,9 @@ M: growable call-next-hooker call-next-method "growable " prepend ;
 [ ] [ "IN: generic.single.tests MATH: xyz ( a b -- c )" eval( -- ) ] unit-test
 
 [ f ] [ "xyz" "generic.single.tests" lookup pic-def>> ] unit-test
-[ f ] [ "xyz" "generic.single.tests" lookup "decision-tree" word-prop ] unit-test
\ No newline at end of file
+[ f ] [ "xyz" "generic.single.tests" lookup "decision-tree" word-prop ] unit-test
+
+! Corner case
+[ "IN: generic.single.tests GENERIC# broken-generic# -1 ( a -- b )" eval( -- ) ]
+[ error>> bad-dispatch-position? ]
+must-fail-with
\ No newline at end of file
index b76bcaa5829add4e5cf5ff271f515709844c9d28..0d1220beac84cddeb5a90dfe03bef2e9f9cf53fe 100644 (file)
@@ -6,9 +6,13 @@ generic.single.private quotations kernel.private
 assocs arrays layouts make ;
 IN: generic.standard
 
+ERROR: bad-dispatch-position # ;
+
 TUPLE: standard-combination < single-combination # ;
 
-C: <standard-combination> standard-combination
+: <standard-combination> ( # -- standard-combination )
+    dup 0 < [ bad-dispatch-position ] when
+    standard-combination boa ;
 
 PREDICATE: standard-generic < generic
     "combination" word-prop standard-combination? ;