]> gitweb.factorcode.org Git - factor.git/commitdiff
core: Throw an error when defining MAIN: with a stack effect other than ( -- ). Fixes...
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 6 Jun 2014 17:54:57 +0000 (10:54 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 6 Jun 2014 17:59:48 +0000 (10:59 -0700)
core/effects/effects.factor
core/syntax/syntax.factor
core/vocabs/vocabs.factor

index bcc2b1e4f6d4c9fac3bee7c0f9f138d03d5e7bab..d875b8e1d1f80ab951c6faa9ae4a67d3817602f7 100644 (file)
@@ -127,3 +127,10 @@ M: effect clone
     [ in>> length ] [ out>> length ] [ terminated?>> ] tri
     pick 0 = [ [ 1 + ] dip ] [ [ 1 - ] 2dip ] if
     [ [ "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 ;
index 7c6ca987644f612f6f0e9ef20e7251a9aa96d198..c115a3c36952e5c48fb6170081f4594da59819b9 100644 (file)
@@ -4,11 +4,11 @@ USING: accessors arrays byte-arrays byte-vectors
 classes.algebra.private classes.builtin classes.intersection
 classes.maybe classes.mixin classes.parser classes.predicate
 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
 generic.standard hash-sets hashtables io.pathnames kernel lexer
 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 ;
 IN: bootstrap.syntax
 
@@ -233,6 +233,7 @@ IN: bootstrap.syntax
 
     "MAIN:" [
         scan-word
+        dup ( -- ) check-stack-effect
         [ current-vocab main<< ]
         [ file get [ main<< ] [ drop ] if* ] bi
     ] define-core-syntax
index 77b3d681d3654eaf19702a66a757cccb1d81671f..1d1b1b5d913b3ee005de2fabfc41860df8db7a9b 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2009 Eduardo Cavazos, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs definitions kernel namespaces sequences
-sorting splitting strings ;
+USING: accessors assocs definitions kernel namespaces
+sequences sorting splitting strings ;
 IN: vocabs
 
 SYMBOL: dictionary