Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: runtime/vm/parser.cc

Issue 49253006: Compile time error on forward references to functions (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/co19/co19-co19.status » ('j') | tests/co19/co19-co19.status » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 29817)
+++ runtime/vm/parser.cc (working copy)
@@ -5557,8 +5557,24 @@
(LookaheadToken(1) != Token::kLPAREN)) {
result_type = ParseType(ClassFinalizer::kCanonicalize);
}
+ intptr_t name_pos = TokenPos();
srdjan 2013/11/04 18:18:55 const
hausner 2013/11/04 18:52:23 Done.
variable_name = ExpectIdentifier("function name expected");
function_name = variable_name;
+
+ // Check that the function name has not been referenced
+ // before this declaration.
+ ASSERT(current_block_ != NULL);
+ const intptr_t previous_pos =
+ current_block_->scope->PreviousReferencePos(*function_name);
+ if (previous_pos >= 0) {
+ ASSERT(!script_.IsNull());
+ intptr_t line_number;
+ script_.GetTokenLocation(previous_pos, &line_number, NULL);
+ ErrorMsg(name_pos,
+ "identifier '%s' previously used in line %" Pd "",
+ function_name->ToCString(),
+ line_number);
+ }
}
if (CurrentToken() != Token::kLPAREN) {
« no previous file with comments | « no previous file | tests/co19/co19-co19.status » ('j') | tests/co19/co19-co19.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698