Permalink
Browse files

Fix compiler breakage if a GENERIC# has an incorrect stack effect dec…

…laration
  • Loading branch information...
Slava Pestov
Slava Pestov committed May 13, 2009
1 parent 4f56f62 commit 302d829ea95c1ec2dffa11084c4a2f9a4d55223c
Showing with 22 additions and 4 deletions.
  1. +17 −1 basis/compiler/tests/optimizer.factor
  2. +5 −3 basis/compiler/tree/propagation/inlining/inlining.factor
@@ -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
+[ -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
@@ -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 -- ? )

0 comments on commit 302d829

Please sign in to comment.