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

Side by Side Diff: runtime/vm/parser.cc

Issue 8619008: Initializing formals can't be optional parameters (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/string_stream.dart ('k') | samples/chat/chat_server_lib.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 parameter.is_field_initializer = true; 833 parameter.is_field_initializer = true;
834 } 834 }
835 // At this point, we must see an identifier for the parameter name. 835 // At this point, we must see an identifier for the parameter name.
836 if (CurrentToken() != Token::kIDENT) { 836 if (CurrentToken() != Token::kIDENT) {
837 ErrorMsg("parameter name expected"); 837 ErrorMsg("parameter name expected");
838 } 838 }
839 parameter.name = CurrentLiteral(); 839 parameter.name = CurrentLiteral();
840 parameter.name_pos = token_index_; 840 parameter.name_pos = token_index_;
841 ConsumeToken(); 841 ConsumeToken();
842 if (parameter.is_field_initializer) { 842 if (parameter.is_field_initializer) {
843 if (params->has_named_optional_parameters) {
Ivan Posva 2011/11/22 19:58:38 A comment explaining how this works would be nice,
844 ErrorMsg(parameter.name_pos,
845 "initializing formal parameter cannot be optional");
846 }
843 params->has_field_initializer = true; 847 params->has_field_initializer = true;
844 } 848 }
845 849
846 if (CurrentToken() == Token::kLPAREN) { 850 if (CurrentToken() == Token::kLPAREN) {
847 // This parameter is probably a closure. If we saw the keyword 'var' 851 // This parameter is probably a closure. If we saw the keyword 'var'
848 // or 'final', a closure is not legal here and we ignore the 852 // or 'final', a closure is not legal here and we ignore the
849 // opening parens. 853 // opening parens.
850 if (!var_seen && !parameter.is_final) { 854 if (!var_seen && !parameter.is_final) {
851 // The parsed parameter type is actually the function result type. 855 // The parsed parameter type is actually the function result type.
852 const Type& result_type = Type::Handle(parameter.type->raw()); 856 const Type& result_type = Type::Handle(parameter.type->raw());
(...skipping 6579 matching lines...) Expand 10 before | Expand all | Expand 10 after
7432 } 7436 }
7433 7437
7434 7438
7435 void Parser::SkipNestedExpr() { 7439 void Parser::SkipNestedExpr() {
7436 const bool saved_mode = SetAllowFunctionLiterals(true); 7440 const bool saved_mode = SetAllowFunctionLiterals(true);
7437 SkipExpr(); 7441 SkipExpr();
7438 SetAllowFunctionLiterals(saved_mode); 7442 SetAllowFunctionLiterals(saved_mode);
7439 } 7443 }
7440 7444
7441 } // namespace dart 7445 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/string_stream.dart ('k') | samples/chat/chat_server_lib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698