]> gitweb.factorcode.org Git - factor.git/commitdiff
Passing an invalid parameter to 'declare' doesn't break the compiler anymore
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 1 May 2009 01:40:47 +0000 (20:40 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 1 May 2009 01:40:47 +0000 (20:40 -0500)
basis/compiler/tests/optimizer.factor
basis/hints/hints.factor
basis/stack-checker/errors/errors.factor
basis/stack-checker/known-words/known-words.factor

index d051031d4a897ccd876a343781c2ec53e61222c8..f19a950711e1993f6b42d3f8e9d6e0df34fdf38a 100644 (file)
@@ -4,7 +4,7 @@ sbufs strings tools.test vectors words sequences.private
 quotations classes classes.algebra classes.tuple.private
 continuations growable namespaces hints alien.accessors
 compiler.tree.builder compiler.tree.optimizer sequences.deep
-compiler ;
+compiler definitions ;
 IN: compiler.tests.optimizer
 
 GENERIC: xyz ( obj -- obj )
@@ -384,3 +384,9 @@ DEFER: loop-bbb
     1 >bignum 2 >bignum
     [ { bignum integer } declare [ shift ] keep 1+ ] compile-call
 ] unit-test
+
+: broken-declaration ( -- ) \ + declare ;
+
+[ f ] [ \ broken-declaration optimized? ] unit-test
+
+[ ] [ [ \ broken-declaration forget ] with-compilation-unit ] unit-test
\ No newline at end of file
index d83275c750d01d40ad8d2781e09dd07063180659..db04033275c3c279291e244a5fdbd66b0512ea88 100644 (file)
@@ -71,7 +71,7 @@ t specialize-method? set-global
 SYNTAX: HINTS:
     scan-object
     [ changed-definition ]
-    [ parse-definition "specializer" set-word-prop ] bi ;
+    [ parse-definition { } like "specializer" set-word-prop ] bi ;
 
 ! Default specializers
 { first first2 first3 first4 }
index e036d4d81b5c2012d6be33ce300044f9f024f0cf..b1071df7080d16ab8cc4d45d65c6731ff8635257 100644 (file)
@@ -33,4 +33,6 @@ ERROR: unknown-primitive-error < inference-error ;
 
 ERROR: transform-expansion-error < inference-error word error ;
 
+ERROR: bad-declaration-error < inference-error declaration ;
+
 M: object (literal) "literal value" literal-expected ;
\ No newline at end of file
index 72eead1826eb830c07f44fa618e8aacfb1680869..d7acf7716242563d7563b5a6962beb9d379f2b83 100644 (file)
@@ -10,7 +10,7 @@ sequences sequences.private slots.private strings
 strings.private system threads.private classes.tuple
 classes.tuple.private vectors vectors.private words definitions
 assocs summary compiler.units system.private
-combinators locals locals.backend locals.types
+combinators combinators.short-circuit locals locals.backend locals.types
 quotations.private combinators.private stack-checker.values
 generic.single generic.single.private
 alien.libraries
@@ -58,8 +58,12 @@ IN: stack-checker.known-words
 : infer-shuffle-word ( word -- )
     "shuffle" word-prop infer-shuffle ;
 
+: check-declaration ( declaration -- declaration )
+    dup { [ array? ] [ [ class? ] all? ] } 1&&
+    [ bad-declaration-error ] unless ;
+
 : infer-declare ( -- )
-    pop-literal nip
+    pop-literal nip check-declaration
     [ length ensure-d ] keep zip
     #declare, ;