jitcraft/Parser.cpp
changeset 72 40746ab0a30b
parent 71 f7e573226c2b
child 74 80e29e23eb4e
     1.1 --- a/jitcraft/Parser.cpp	Sat Jul 14 18:43:34 2012 -0700
     1.2 +++ b/jitcraft/Parser.cpp	Sat Jul 14 21:01:52 2012 -0700
     1.3 @@ -621,11 +621,15 @@
     1.4      if (!expect(TOK_RETURN))
     1.5          return NULL;
     1.6  
     1.7 -    Expression *expr = expression();
     1.8 -    if (!expr)
     1.9 -        return NULL;
    1.10 +    Expression *expr = NULL;
    1.11 +    if (scanner_.peek() != TOK_SEMICOLON) {
    1.12 +        if ((expr = expression()) == NULL)
    1.13 +            return NULL;
    1.14  
    1.15 -    encounteredReturn_ = true;
    1.16 +        // We only care about non-void returns when determining whether a
    1.17 +        // tagless function is non-void.
    1.18 +        encounteredReturn_ = true;
    1.19 +    }
    1.20  
    1.21      return new (pool_) ReturnStatement(pos, expr);
    1.22  }
    1.23 @@ -1100,7 +1104,8 @@
    1.24          prefix();
    1.25          fprintf(fp_, "[ ReturnStatement\n");
    1.26          indent();
    1.27 -        node->expression()->accept(this);
    1.28 +        if (node->expression())
    1.29 +            node->expression()->accept(this);
    1.30          unindent();
    1.31      }
    1.32      void visit(ForStatement *node) {