Index: runtime/vm/parser.cc |
=================================================================== |
--- runtime/vm/parser.cc (revision 29679) |
+++ runtime/vm/parser.cc (working copy) |
@@ -5260,10 +5260,27 @@ |
TRACE_PARSER("ParseVariableDeclaration"); |
ASSERT(IsIdentifier()); |
const intptr_t ident_pos = TokenPos(); |
- LocalVariable* variable = |
- new LocalVariable(ident_pos, *CurrentLiteral(), type); |
+ const String& ident = *CurrentLiteral(); |
+ LocalVariable* variable = new LocalVariable(ident_pos, ident, type); |
ASSERT(current_block_ != NULL); |
ASSERT(current_block_->scope != NULL); |
+ const intptr_t previous_pos = |
+ current_block_->scope->PreviousReferencePos(ident); |
+ if (previous_pos >= 0) { |
+ ASSERT(!script_.IsNull()); |
+ if (script_.HasSource()) { |
+ intptr_t line_number; |
+ script_.GetTokenLocation(previous_pos, &line_number, NULL); |
Ivan Posva
2013/11/01 16:35:12
Since we are only getting the line number here we
hausner
2013/11/01 16:42:51
True. I figured line numbers make less sense if a
|
+ ErrorMsg(ident_pos, |
+ "identifier '%s' previously used in line %" Pd "", |
+ ident.ToCString(), |
+ line_number); |
+ } else { |
+ ErrorMsg(ident_pos, |
+ "identifier '%s' previously used in this scope", |
+ ident.ToCString()); |
+ } |
+ } |
ConsumeToken(); // Variable identifier. |
AstNode* initialization = NULL; |
if (CurrentToken() == Token::kASSIGN) { |
@@ -8776,6 +8793,9 @@ |
TRACE_PARSER("ResolveIdentInLocalScope"); |
// First try to find the identifier in the nested local scopes. |
LocalVariable* local = LookupLocalScope(ident); |
+ if (current_block_ != NULL) { |
+ current_block_->scope->AddReferencedName(ident_pos, ident); |
+ } |
if (local != NULL) { |
if (node != NULL) { |
if (local->IsConst()) { |
@@ -9120,6 +9140,11 @@ |
} |
QualIdent type_name; |
if (finalization == ClassFinalizer::kIgnore) { |
+ if (!is_top_level_ && (current_block_ != NULL)) { |
+ // Add the library prefix or type class name to the list of referenced |
+ // names of this scope, even if the type is ignored. |
+ current_block_->scope->AddReferencedName(TokenPos(), *CurrentLiteral()); |
+ } |
SkipQualIdent(); |
} else { |
ParseQualIdent(&type_name); |