Passing an invalid parameter to 'declare' doesn't break the compiler anymore

db4
Slava Pestov 2009-04-30 20:40:47 -05:00
parent 10e21bf8d3
commit a79e3eb687
4 changed files with 16 additions and 4 deletions

View File

@ -4,7 +4,7 @@ sbufs strings tools.test vectors words sequences.private
quotations classes classes.algebra classes.tuple.private quotations classes classes.algebra classes.tuple.private
continuations growable namespaces hints alien.accessors continuations growable namespaces hints alien.accessors
compiler.tree.builder compiler.tree.optimizer sequences.deep compiler.tree.builder compiler.tree.optimizer sequences.deep
compiler ; compiler definitions ;
IN: compiler.tests.optimizer IN: compiler.tests.optimizer
GENERIC: xyz ( obj -- obj ) GENERIC: xyz ( obj -- obj )
@ -384,3 +384,9 @@ DEFER: loop-bbb
1 >bignum 2 >bignum 1 >bignum 2 >bignum
[ { bignum integer } declare [ shift ] keep 1+ ] compile-call [ { bignum integer } declare [ shift ] keep 1+ ] compile-call
] unit-test ] unit-test
: broken-declaration ( -- ) \ + declare ;
[ f ] [ \ broken-declaration optimized? ] unit-test
[ ] [ [ \ broken-declaration forget ] with-compilation-unit ] unit-test

View File

@ -71,7 +71,7 @@ t specialize-method? set-global
SYNTAX: HINTS: SYNTAX: HINTS:
scan-object scan-object
[ changed-definition ] [ changed-definition ]
[ parse-definition "specializer" set-word-prop ] bi ; [ parse-definition { } like "specializer" set-word-prop ] bi ;
! Default specializers ! Default specializers
{ first first2 first3 first4 } { first first2 first3 first4 }

View File

@ -33,4 +33,6 @@ ERROR: unknown-primitive-error < inference-error ;
ERROR: transform-expansion-error < inference-error word error ; ERROR: transform-expansion-error < inference-error word error ;
ERROR: bad-declaration-error < inference-error declaration ;
M: object (literal) "literal value" literal-expected ; M: object (literal) "literal value" literal-expected ;

View File

@ -10,7 +10,7 @@ sequences sequences.private slots.private strings
strings.private system threads.private classes.tuple strings.private system threads.private classes.tuple
classes.tuple.private vectors vectors.private words definitions classes.tuple.private vectors vectors.private words definitions
assocs summary compiler.units system.private 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 quotations.private combinators.private stack-checker.values
generic.single generic.single.private generic.single generic.single.private
alien.libraries alien.libraries
@ -58,8 +58,12 @@ IN: stack-checker.known-words
: infer-shuffle-word ( word -- ) : infer-shuffle-word ( word -- )
"shuffle" word-prop infer-shuffle ; "shuffle" word-prop infer-shuffle ;
: check-declaration ( declaration -- declaration )
dup { [ array? ] [ [ class? ] all? ] } 1&&
[ bad-declaration-error ] unless ;
: infer-declare ( -- ) : infer-declare ( -- )
pop-literal nip pop-literal nip check-declaration
[ length ensure-d ] keep zip [ length ensure-d ] keep zip
#declare, ; #declare, ;