Index: runtime/vm/parser.cc |
=================================================================== |
--- runtime/vm/parser.cc (revision 14798) |
+++ runtime/vm/parser.cc (working copy) |
@@ -4474,6 +4474,10 @@ |
return; |
} |
+ const bool is_script = (script_.kind() == RawScript::kScriptTag); |
+ const bool is_library = (script_.kind() == RawScript::kLibraryTag); |
+ ASSERT(script_.kind() != RawScript::kSourceTag); |
+ |
// We may read metadata tokens that are part of the toplevel |
// declaration that follows the library definitions. Therefore, we |
// need to remember the position of the last token that was |
@@ -4484,11 +4488,14 @@ |
ParseLibraryName(); |
metadata_pos = TokenPos(); |
SkipMetadata(); |
- } else if (script_.kind() == RawScript::kLibraryTag) { |
+ } else if (is_library) { |
siva
2012/11/13 00:21:53
isn't this equivalent to
else if (!is_script) {
..
hausner
2012/11/13 01:07:13
Keeping as is, as per our offline discussion.
On
|
ErrorMsg("library name definition expected"); |
} |
while ((CurrentToken() == Token::kIMPORT) || |
(CurrentToken() == Token::kEXPORT)) { |
+ if (is_script && (CurrentToken() == Token::kEXPORT)) { |
+ ErrorMsg("export not allowed in scripts"); |
+ } |
ParseLibraryImportExport(); |
metadata_pos = TokenPos(); |
SkipMetadata(); |