diff --git a/basis/compiler/tests/optimizer.factor b/basis/compiler/tests/optimizer.factor index d051031d4a..f19a950711 100644 --- a/basis/compiler/tests/optimizer.factor +++ b/basis/compiler/tests/optimizer.factor @@ -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 diff --git a/basis/hints/hints.factor b/basis/hints/hints.factor index d83275c750..db04033275 100644 --- a/basis/hints/hints.factor +++ b/basis/hints/hints.factor @@ -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 } diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index e036d4d81b..b1071df708 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -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 diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 72eead1826..d7acf77162 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -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, ;