src/Parser.cpp
changeset 189 eee18bf13c9b
parent 187 9308d52205a0
child 191 9d17f29fe16a
     1.1 --- a/src/Parser.cpp	Sun Sep 16 21:34:10 2012 -0700
     1.2 +++ b/src/Parser.cpp	Sun Sep 16 21:59:18 2012 -0700
     1.3 @@ -865,18 +865,13 @@
     1.4      if (!name)
     1.5          return NULL;
     1.6  
     1.7 +    SourcePosition pos = scanner_.begin();
     1.8 +
     1.9      if (BoundName *other = scope_->localLookup(name)) {
    1.10          redeclarationError(other);
    1.11          return NULL;
    1.12      }
    1.13  
    1.14 -    Variable *var = scope_->declareVariable(name, scanner_.begin());
    1.15 -    if (!var)
    1.16 -        return NULL;
    1.17 -
    1.18 -    if (scope == TOK_PUBLIC)
    1.19 -        var->setPublic();
    1.20 -
    1.21      ExpressionList *postDimensions = NULL;
    1.22      if (peek(TOK_LBRACKET)) {
    1.23          if ((postDimensions = dimensions()) == NULL)
    1.24 @@ -899,6 +894,13 @@
    1.25          }
    1.26      }
    1.27  
    1.28 +    Variable *var = scope_->declareVariable(name, pos);
    1.29 +    if (!var)
    1.30 +        return NULL;
    1.31 +
    1.32 +    if (scope == TOK_PUBLIC)
    1.33 +        var->setPublic();
    1.34 +
    1.35      return new (pool_) VariableDeclaration(var->pos(), kind, var, type, postDimensions, expr);
    1.36  }
    1.37