Message from discussion
r12665 committed - Reject local module declarations....
Received: by 10.224.31.20 with SMTP id w20mr6986929qac.2.1349428481292;
Fri, 05 Oct 2012 02:14:41 -0700 (PDT)
X-BeenThere: v8-dev@googlegroups.com
Received: by 10.229.135.3 with SMTP id l3ls4655458qct.6.gmail; Fri, 05 Oct
2012 02:14:40 -0700 (PDT)
Received: by 10.224.213.1 with SMTP id gu1mr6982315qab.7.1349428479979;
Fri, 05 Oct 2012 02:14:39 -0700 (PDT)
Received: by 10.224.213.1 with SMTP id gu1mr6982314qab.7.1349428479962;
Fri, 05 Oct 2012 02:14:39 -0700 (PDT)
Return-Path: <3_6RuUBAKBows4tu8y9u-347u51Ew44w1u.s42BO-tuBw44w1uw74A58....@codesite.bounces.google.com>
Received: from mail-qa0-f75.google.com (mail-qa0-f75.google.com [209.85.216.75])
by gmr-mx.google.com with ESMTPS id g28si1991648qcq.2.2012.10.05.02.14.39
(version=TLSv1/SSLv3 cipher=OTHER);
Fri, 05 Oct 2012 02:14:39 -0700 (PDT)
Received-SPF: pass (google.com: domain of 3_6RuUBAKBows4tu8y9u-347u51Ew44w1u.s42BO-tuBw44w1uw74A58....@codesite.bounces.google.com designates 209.85.216.75 as permitted sender) client-ip=209.85.216.75;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of 3_6RuUBAKBows4tu8y9u-347u51Ew44w1u.s42BO-tuBw44w1uw74A58....@codesite.bounces.google.com designates 209.85.216.75 as permitted sender) smtp.mail=3_6RuUBAKBows4tu8y9u-347u51Ew44w1u.s42BO-tuBw44w1uw74A58....@codesite.bounces.google.com; dkim=pass header...@google.com
Received: by mail-qa0-f75.google.com with SMTP id b12so1988qad.4
for <v8-dev@googlegroups.com>; Fri, 05 Oct 2012 02:14:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=google.com; s=20120113;
h=mime-version:x-generated-by:message-id:date:subject:from:to
:content-type;
bh=2JcGrakWTCvZ0N+IJhwaz5QtSJSDHiZLApzjaon0VzU=;
b=AelMAUecZqFYP0FzvXEyt2OpDWj7V/R+lNL1SlRsds2Eq5zN2w8x2wavw4xjQHPR1V
1jHRWB3MqpBmWeBvVOfmZJkg63FkvuxMHmcjHjWbbMYYW4IHhFa4FMR6t/xX9ONRAf4C
+mMQGG/nc/lQ71osbs7la87lOQV54tmAuGNX+M3jW3AkeAexaNVjoWa8KQh2cWFB9SkY
eSzmw//1JT7bTp3FowwEjqLRBcIAVmnX1Di7YfBgD/Ny4bnF/ABuK4g2CPwM8p4S5pUQ
oGuXeh2uF+OBrl40sBnSItl4SygJalBQ5HPig48kiFt80nu6nnBvdEFwLPPTarPTd4tw
XCEg==
MIME-Version: 1.0
Received: by 10.224.70.131 with SMTP id d3mr6989011qaj.0.1349428479734; Fri,
05 Oct 2012 02:14:39 -0700 (PDT)
X-Generated-By: Google Code
Message-ID: <bcaec51ba5932f360004cb4c4...@google.com>
Date: Fri, 05 Oct 2012 09:14:39 +0000
Subject: [v8] r12665 committed - Reject local module declarations....
From: codesite-nore...@google.com
To: v8-dev@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes
Revision: 12665
Author: rossb...@chromium.org
Date: Fri Oct 5 02:14:08 2012
Log: Reject local module declarations.
R=mstarzin...@chromium.org
BUG=150628
Review URL: https://codereview.chromium.org/11033025
http://code.google.com/p/v8/source/detail?r=12665
Modified:
/branches/bleeding_edge/src/parser.cc
/branches/bleeding_edge/src/parser.h
/branches/bleeding_edge/test/mjsunit/harmony/module-parsing.js
=======================================
--- /branches/bleeding_edge/src/parser.cc Fri Oct 5 02:07:53 2012
+++ /branches/bleeding_edge/src/parser.cc Fri Oct 5 02:14:08 2012
@@ -642,7 +642,7 @@
ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16,
zone());
bool ok = true;
int beg_loc = scanner().location().beg_pos;
- ParseSourceElements(body, Token::EOS, info->is_eval(), &ok);
+ ParseSourceElements(body, Token::EOS, info->is_eval(), true, &ok);
if (ok && !top_scope_->is_classic_mode()) {
CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok);
}
@@ -1007,6 +1007,7 @@
void* Parser::ParseSourceElements(ZoneList<Statement*>* processor,
int end_token,
bool is_eval,
+ bool is_global,
bool* ok) {
// SourceElements ::
// (ModuleElement)* <end_token>
@@ -1028,7 +1029,12 @@
}
Scanner::Location token_loc = scanner().peek_location();
- Statement* stat = ParseModuleElement(NULL, CHECK_OK);
+ Statement* stat;
+ if (is_global && !is_eval) {
+ stat = ParseModuleElement(NULL, CHECK_OK);
+ } else {
+ stat = ParseBlockElement(NULL, CHECK_OK);
+ }
if (stat == NULL || stat->IsEmpty()) {
directive_prologue = false; // End of directive prologue.
continue;
@@ -4533,7 +4539,7 @@
RelocInfo::kNoPosition)),
zone());
}
- ParseSourceElements(body, Token::RBRACE, false, CHECK_OK);
+ ParseSourceElements(body, Token::RBRACE, false, false, CHECK_OK);
materialized_literal_count =
function_state.materialized_literal_count();
expected_property_count = function_state.expected_property_count();
=======================================
--- /branches/bleeding_edge/src/parser.h Mon Sep 24 09:22:17 2012
+++ /branches/bleeding_edge/src/parser.h Fri Oct 5 02:14:08 2012
@@ -590,8 +590,8 @@
// which is set to false if parsing failed; it is unchanged otherwise.
// By making the 'exception handling' explicit, we are forced to check
// for failure at the call sites.
- void* ParseSourceElements(ZoneList<Statement*>* processor,
- int end_token, bool is_eval, bool* ok);
+ void* ParseSourceElements(ZoneList<Statement*>* processor, int end_token,
+ bool is_eval, bool is_global, bool* ok);
Statement* ParseModuleElement(ZoneStringList* labels, bool* ok);
Statement* ParseModuleDeclaration(ZoneStringList* names, bool* ok);
Module* ParseModule(bool* ok);
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/module-parsing.js Mon Jul
9 01:59:03 2012
+++ /branches/bleeding_edge/test/mjsunit/harmony/module-parsing.js Fri Oct
5 02:14:08 2012
@@ -162,3 +162,29 @@
module
v = 20
+
+
+
+// Check that module declarations are rejected in eval or local scope.
+
+module M { export let x; }
+
+assertThrows("export x;", SyntaxError); // It's using eval, so should
throw.
+assertThrows("export let x;", SyntaxError);
+assertThrows("import x from M;", SyntaxError);
+assertThrows("module M {};", SyntaxError);
+
+assertThrows("{ export x; }", SyntaxError);
+assertThrows("{ export let x; }", SyntaxError);
+assertThrows("{ import x from M; }", SyntaxError);
+assertThrows("{ module M {}; }", SyntaxError);
+
+assertThrows("function f() { export x; }", SyntaxError);
+assertThrows("function f() { export let x; }", SyntaxError);
+assertThrows("function f() { import x from M; }", SyntaxError);
+assertThrows("function f() { module M {}; }", SyntaxError);
+
+assertThrows("function f() { { export x; } }", SyntaxError);
+assertThrows("function f() { { export let x; } }", SyntaxError);
+assertThrows("function f() { { import x from M; } }", SyntaxError);
+assertThrows("function f() { { module M {}; } }", SyntaxError);