]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix compiler breakage if a GENERIC# has an incorrect stack effect declaration
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 13 May 2009 02:23:52 +0000 (21:23 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 13 May 2009 02:23:52 +0000 (21:23 -0500)
basis/compiler/tests/optimizer.factor
basis/compiler/tree/propagation/inlining/inlining.factor

index fa1248435bf1806a9aa48f450ccb7d8fdb8af44f..72618db4569740d4d583d83e9c1dc30bae19fa2d 100644 (file)
@@ -395,4 +395,20 @@ DEFER: loop-bbb
 : modular-arithmetic-bug ( a -- b ) >integer 256 mod ;
 
 [ 1 ] [ 257 modular-arithmetic-bug ] unit-test
-[ -10 ] [ -10 modular-arithmetic-bug ] unit-test
\ No newline at end of file
+[ -10 ] [ -10 modular-arithmetic-bug ] unit-test
+
+! Optimizer needs to ignore invalid generics
+GENERIC# bad-dispatch-position-test* 3 ( -- )
+
+M: object bad-dispatch-position-test* ;
+
+: bad-dispatch-position-test ( -- ) bad-dispatch-position-test* ;
+
+[ 1 2 3 4 bad-dispatch-position-test ] must-fail
+
+[ ] [
+    [
+        \ bad-dispatch-position-test forget
+        \ bad-dispatch-position-test* forget
+    ] with-compilation-unit
+] unit-test
\ No newline at end of file
index ee9abf00ec1301e4e65996eb7fba6286cac57d6f..6be3bed8d3adfa451c12f3a93a9e0f77b4a8c8e9 100755 (executable)
@@ -59,9 +59,11 @@ M: callable splicing-nodes splicing-body ;
 
 : inlining-standard-method ( #call word -- class/f method/f )
     dup "methods" word-prop assoc-empty? [ 2drop f f ] [
-        [ in-d>> <reversed> ] [ [ dispatch# ] keep ] bi*
-        [ swap nth value-info class>> dup ] dip
-        specific-method
+        2dup [ in-d>> length ] [ dispatch# ] bi* <= [ 2drop f f ] [
+            [ in-d>> <reversed> ] [ [ dispatch# ] keep ] bi*
+            [ swap nth value-info class>> dup ] dip
+            specific-method
+        ] if
     ] if ;
 
 : inline-standard-method ( #call word -- ? )