core: Throw an error when defining MAIN: with a stack effect other than ( -- ). Fixes #1060.

db4
Doug Coleman 2014-06-06 10:54:57 -07:00
parent 309ce3aa69
commit afcb610960
3 changed files with 12 additions and 4 deletions

View File

@ -127,3 +127,10 @@ M: effect clone
[ in>> length ] [ out>> length ] [ terminated?>> ] tri [ in>> length ] [ out>> length ] [ terminated?>> ] tri
pick 0 = [ [ 1 + ] dip ] [ [ 1 - ] 2dip ] if pick 0 = [ [ 1 + ] dip ] [ [ 1 - ] 2dip ] if
[ [ "x" <array> ] bi@ ] dip <terminated-effect> ; [ [ "x" <array> ] bi@ ] dip <terminated-effect> ;
ERROR: bad-stack-effect word expected got ;
: check-stack-effect ( word effect -- )
[ dup stack-effect ] dip
2dup effect=
[ 3drop ] [ bad-stack-effect ] if ;

View File

@ -4,11 +4,11 @@ USING: accessors arrays byte-arrays byte-vectors
classes.algebra.private classes.builtin classes.intersection classes.algebra.private classes.builtin classes.intersection
classes.maybe classes.mixin classes.parser classes.predicate classes.maybe classes.mixin classes.parser classes.predicate
classes.singleton classes.tuple classes.tuple.parser classes.singleton classes.tuple classes.tuple.parser
classes.union combinators compiler.units definitions classes.union combinators compiler.units definitions effects
effects.parser generic generic.hook generic.math generic.parser effects.parser generic generic.hook generic.math generic.parser
generic.standard hash-sets hashtables io.pathnames kernel lexer generic.standard hash-sets hashtables io.pathnames kernel lexer
math namespaces parser quotations sbufs sequences slots math namespaces parser quotations sbufs sequences slots
source-files splitting strings strings.parser vectors source-files splitting strings strings.parser vectors vocabs
vocabs.parser words words.alias words.constant words.symbol ; vocabs.parser words words.alias words.constant words.symbol ;
IN: bootstrap.syntax IN: bootstrap.syntax
@ -233,6 +233,7 @@ IN: bootstrap.syntax
"MAIN:" [ "MAIN:" [
scan-word scan-word
dup ( -- ) check-stack-effect
[ current-vocab main<< ] [ current-vocab main<< ]
[ file get [ main<< ] [ drop ] if* ] bi [ file get [ main<< ] [ drop ] if* ] bi
] define-core-syntax ] define-core-syntax

View File

@ -1,7 +1,7 @@
! Copyright (C) 2007, 2009 Eduardo Cavazos, Slava Pestov. ! Copyright (C) 2007, 2009 Eduardo Cavazos, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs definitions kernel namespaces sequences USING: accessors assocs definitions kernel namespaces
sorting splitting strings ; sequences sorting splitting strings ;
IN: vocabs IN: vocabs
SYMBOL: dictionary SYMBOL: dictionary