Reviewers: Dan Ehrenberg, rossberg,

Message:
PTAL

Description:
[es6] Handle conflicts for sloppy let

We have to call CheckConflictingVarDeclarations in case we have enabled
--harmony-sloppy

BUG=v8:4287
LOG=N
[email protected], [email protected]

Please review this at https://codereview.chromium.org/1226103002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+19, -6 lines):
  M src/parser.cc
  M src/preparser.h
  A + test/mjsunit/harmony/block-conflicts-sloppy.js


Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 753391193bf03667a685a24161b83e53ca3ecbda..972787f05877d8be6e5591dfb73ce90354504787 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1062,6 +1062,8 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {

     if (ok && is_strict(language_mode())) {
       CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
+    }
+    if (ok && (is_strict(language_mode()) || allow_harmony_sloppy())) {
       CheckConflictingVarDeclarations(scope_, &ok);
     }

@@ -4141,6 +4143,8 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
     if (is_strict(language_mode())) {
CheckStrictOctalLiteral(scope->start_position(), scope->end_position(),
                               CHECK_OK);
+    }
+    if (is_strict(language_mode()) || allow_harmony_sloppy()) {
       CheckConflictingVarDeclarations(scope, CHECK_OK);
     }
   }
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index aa866647d1eb99ad426b5f7e9dbd116a531edd6f..2f1e740d1935d02c1a3d7740ec9c4b76e6c185e2 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -3765,6 +3765,8 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
     if (is_strict(language_mode())) {
       CheckStrictOctalLiteral(formal_parameters.scope->start_position(),
                               scanner()->location().end_pos, CHECK_OK);
+    }
+    if (is_strict(language_mode()) || allow_harmony_sloppy()) {
this->CheckConflictingVarDeclarations(formal_parameters.scope, CHECK_OK);
     }
   }
Index: test/mjsunit/harmony/block-conflicts-sloppy.js
diff --git a/test/mjsunit/es6/block-conflicts.js b/test/mjsunit/harmony/block-conflicts-sloppy.js
similarity index 84%
copy from test/mjsunit/es6/block-conflicts.js
copy to test/mjsunit/harmony/block-conflicts-sloppy.js
index fdd581dd70b0e7b1d840054f527d6dcc940f24c7..70b2017b117a3ba1b3e7b3315d8920eb03532bad 100644
--- a/test/mjsunit/es6/block-conflicts.js
+++ b/test/mjsunit/harmony/block-conflicts-sloppy.js
@@ -4,7 +4,7 @@

 // Test for conflicting variable bindings.

-"use strict";
+// Flags: --no-legacy-const --harmony-sloppy

 function CheckException(e) {
   var string = e.toString();
@@ -44,8 +44,10 @@ function TestAll(expected,s,opt_e) {
   var e = "";
   var msg = s;
   if (opt_e) { e = opt_e; msg += opt_e; }
-  assertEquals(expected === 'LocalConflict' ? 'NoConflict' : expected,
-      TestGlobal(s,e), "global:'" + msg + "'");
+  // TODO(littledan): https://code.google.com/p/v8/issues/detail?id=4288
+  // It is also not clear whether these tests makes sense in sloppy mode.
+  // assertEquals(expected === 'LocalConflict' ? 'NoConflict' : expected,
+  //     TestGlobal(s,e), "global:'" + msg + "'");
   assertEquals(expected === 'LocalConflict' ? 'NoConflict' : expected,
       TestFunction(s,e), "function:'" + msg + "'");
   assertEquals(expected === 'LocalConflict' ? 'Conflict' : expected,
@@ -55,17 +57,22 @@ function TestAll(expected,s,opt_e) {

 function TestConflict(s) {
   TestAll('Conflict', s);
-  TestAll('Conflict', 'eval("' + s + '");');
+  // TODO(littledan): https://code.google.com/p/v8/issues/detail?id=4288
+  // It is also not clear whether these tests makes sense in sloppy mode.
+  // TestAll('Conflict', 'eval("' + s + '");');
 }

 function TestNoConflict(s) {
   TestAll('NoConflict', s, "'NoConflict'");
-  TestAll('NoConflict', 'eval("' + s + '");', "'NoConflict'");
+  // TODO(littledan): https://code.google.com/p/v8/issues/detail?id=4288
+  // TestAll('NoConflict', 'eval("' + s + '");', "'NoConflict'");
 }

 function TestLocalConflict(s) {
   TestAll('LocalConflict', s, "'NoConflict'");
-  TestAll('NoConflict', 'eval("' + s + '");', "'NoConflict'");
+  // TODO(littledan): https://code.google.com/p/v8/issues/detail?id=4288
+  // It is also not clear whether these tests makes sense in sloppy mode.
+  // TestAll('NoConflict', 'eval("' + s + '");', "'NoConflict'");
 }

 var letbinds = [ "let x;",


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to