Commit 2d2b72f6 authored by littledan's avatar littledan Committed by Commit bot

Split off a separate --harmony_sloppy_let flag

--harmony_sloppy includes behavior to turn on sloppy mode lexical
bindings. Before this patch, it also included a way to parse let
which is likely web-incompatible (let is disallowed as an
identifier). This patch splits off the let parsing from the more
general block scoping code, so that block scoping can be developed
independently.

R=adamk
LOG=N
BUG=v8:3305

Review URL: https://codereview.chromium.org/1255013002

Cr-Commit-Position: refs/heads/master@{#29855}
parent f06754a8
...@@ -1864,6 +1864,7 @@ EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_regexps) ...@@ -1864,6 +1864,7 @@ EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_regexps)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy_let)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names) EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names)
...@@ -1900,6 +1901,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes) ...@@ -1900,6 +1901,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_let)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters)
...@@ -2578,6 +2580,7 @@ bool Genesis::InstallExperimentalNatives() { ...@@ -2578,6 +2580,7 @@ bool Genesis::InstallExperimentalNatives() {
static const char* harmony_tostring_natives[] = {"native harmony-tostring.js", static const char* harmony_tostring_natives[] = {"native harmony-tostring.js",
nullptr}; nullptr};
static const char* harmony_sloppy_natives[] = {nullptr}; static const char* harmony_sloppy_natives[] = {nullptr};
static const char* harmony_sloppy_let_natives[] = {nullptr};
static const char* harmony_unicode_natives[] = {nullptr}; static const char* harmony_unicode_natives[] = {nullptr};
static const char* harmony_unicode_regexps_natives[] = {nullptr}; static const char* harmony_unicode_regexps_natives[] = {nullptr};
static const char* harmony_computed_property_names_natives[] = {nullptr}; static const char* harmony_computed_property_names_natives[] = {nullptr};
......
...@@ -191,6 +191,7 @@ DEFINE_BOOL(legacy_const, true, "legacy semantics for const in sloppy mode") ...@@ -191,6 +191,7 @@ DEFINE_BOOL(legacy_const, true, "legacy semantics for const in sloppy mode")
V(harmony_regexps, "harmony regular expression extensions") \ V(harmony_regexps, "harmony regular expression extensions") \
V(harmony_proxies, "harmony proxies") \ V(harmony_proxies, "harmony proxies") \
V(harmony_sloppy, "harmony features in sloppy mode") \ V(harmony_sloppy, "harmony features in sloppy mode") \
V(harmony_sloppy_let, "harmony let in sloppy mode") \
V(harmony_unicode_regexps, "harmony unicode regexps") \ V(harmony_unicode_regexps, "harmony unicode regexps") \
V(harmony_reflect, "harmony Reflect API") \ V(harmony_reflect, "harmony Reflect API") \
V(harmony_destructuring, "harmony destructuring") \ V(harmony_destructuring, "harmony destructuring") \
...@@ -240,6 +241,7 @@ HARMONY_SHIPPING(FLAG_SHIPPING_FEATURES) ...@@ -240,6 +241,7 @@ HARMONY_SHIPPING(FLAG_SHIPPING_FEATURES)
// Feature dependencies. // Feature dependencies.
DEFINE_IMPLICATION(harmony_unicode_regexps, harmony_unicode) DEFINE_IMPLICATION(harmony_unicode_regexps, harmony_unicode)
DEFINE_IMPLICATION(harmony_sloppy_let, harmony_sloppy)
// Flags for experimental implementation features. // Flags for experimental implementation features.
......
...@@ -913,6 +913,7 @@ Parser::Parser(ParseInfo* info) ...@@ -913,6 +913,7 @@ Parser::Parser(ParseInfo* info)
set_allow_harmony_modules(!info->is_native() && FLAG_harmony_modules); set_allow_harmony_modules(!info->is_native() && FLAG_harmony_modules);
set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions); set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions);
set_allow_harmony_sloppy(FLAG_harmony_sloppy); set_allow_harmony_sloppy(FLAG_harmony_sloppy);
set_allow_harmony_sloppy_let(FLAG_harmony_sloppy_let);
set_allow_harmony_unicode(FLAG_harmony_unicode); set_allow_harmony_unicode(FLAG_harmony_unicode);
set_allow_harmony_computed_property_names( set_allow_harmony_computed_property_names(
FLAG_harmony_computed_property_names); FLAG_harmony_computed_property_names);
...@@ -4459,6 +4460,7 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( ...@@ -4459,6 +4460,7 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser(
SET_ALLOW(harmony_modules); SET_ALLOW(harmony_modules);
SET_ALLOW(harmony_arrow_functions); SET_ALLOW(harmony_arrow_functions);
SET_ALLOW(harmony_sloppy); SET_ALLOW(harmony_sloppy);
SET_ALLOW(harmony_sloppy_let);
SET_ALLOW(harmony_unicode); SET_ALLOW(harmony_unicode);
SET_ALLOW(harmony_computed_property_names); SET_ALLOW(harmony_computed_property_names);
SET_ALLOW(harmony_rest_params); SET_ALLOW(harmony_rest_params);
......
...@@ -101,6 +101,7 @@ class ParserBase : public Traits { ...@@ -101,6 +101,7 @@ class ParserBase : public Traits {
allow_natives_(false), allow_natives_(false),
allow_harmony_arrow_functions_(false), allow_harmony_arrow_functions_(false),
allow_harmony_sloppy_(false), allow_harmony_sloppy_(false),
allow_harmony_sloppy_let_(false),
allow_harmony_computed_property_names_(false), allow_harmony_computed_property_names_(false),
allow_harmony_rest_params_(false), allow_harmony_rest_params_(false),
allow_harmony_spreadcalls_(false), allow_harmony_spreadcalls_(false),
...@@ -118,6 +119,7 @@ class ParserBase : public Traits { ...@@ -118,6 +119,7 @@ class ParserBase : public Traits {
ALLOW_ACCESSORS(natives); ALLOW_ACCESSORS(natives);
ALLOW_ACCESSORS(harmony_arrow_functions); ALLOW_ACCESSORS(harmony_arrow_functions);
ALLOW_ACCESSORS(harmony_sloppy); ALLOW_ACCESSORS(harmony_sloppy);
ALLOW_ACCESSORS(harmony_sloppy_let);
ALLOW_ACCESSORS(harmony_computed_property_names); ALLOW_ACCESSORS(harmony_computed_property_names);
ALLOW_ACCESSORS(harmony_rest_params); ALLOW_ACCESSORS(harmony_rest_params);
ALLOW_ACCESSORS(harmony_spreadcalls); ALLOW_ACCESSORS(harmony_spreadcalls);
...@@ -504,7 +506,7 @@ class ParserBase : public Traits { ...@@ -504,7 +506,7 @@ class ParserBase : public Traits {
} }
bool allow_let() { bool allow_let() {
return is_strict(language_mode()) || allow_harmony_sloppy(); return is_strict(language_mode()) || allow_harmony_sloppy_let();
} }
// Report syntax errors. // Report syntax errors.
...@@ -797,6 +799,7 @@ class ParserBase : public Traits { ...@@ -797,6 +799,7 @@ class ParserBase : public Traits {
bool allow_natives_; bool allow_natives_;
bool allow_harmony_arrow_functions_; bool allow_harmony_arrow_functions_;
bool allow_harmony_sloppy_; bool allow_harmony_sloppy_;
bool allow_harmony_sloppy_let_;
bool allow_harmony_computed_property_names_; bool allow_harmony_computed_property_names_;
bool allow_harmony_rest_params_; bool allow_harmony_rest_params_;
bool allow_harmony_spreadcalls_; bool allow_harmony_spreadcalls_;
......
...@@ -1431,6 +1431,7 @@ enum ParserFlag { ...@@ -1431,6 +1431,7 @@ enum ParserFlag {
kAllowHarmonyArrowFunctions, kAllowHarmonyArrowFunctions,
kAllowHarmonyRestParameters, kAllowHarmonyRestParameters,
kAllowHarmonySloppy, kAllowHarmonySloppy,
kAllowHarmonySloppyLet,
kAllowHarmonyUnicode, kAllowHarmonyUnicode,
kAllowHarmonyComputedPropertyNames, kAllowHarmonyComputedPropertyNames,
kAllowHarmonySpreadCalls, kAllowHarmonySpreadCalls,
...@@ -1461,6 +1462,7 @@ void SetParserFlags(i::ParserBase<Traits>* parser, ...@@ -1461,6 +1462,7 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
parser->set_allow_harmony_spreadcalls( parser->set_allow_harmony_spreadcalls(
flags.Contains(kAllowHarmonySpreadCalls)); flags.Contains(kAllowHarmonySpreadCalls));
parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy));
parser->set_allow_harmony_sloppy_let(flags.Contains(kAllowHarmonySloppyLet));
parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode)); parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode));
parser->set_allow_harmony_computed_property_names( parser->set_allow_harmony_computed_property_names(
flags.Contains(kAllowHarmonyComputedPropertyNames)); flags.Contains(kAllowHarmonyComputedPropertyNames));
...@@ -6841,7 +6843,8 @@ TEST(LetSloppy) { ...@@ -6841,7 +6843,8 @@ TEST(LetSloppy) {
}; };
// clang-format on // clang-format on
static const ParserFlag always_flags[] = {kAllowHarmonySloppy}; static const ParserFlag always_flags[] = {kAllowHarmonySloppy,
kAllowHarmonySloppyLet};
RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
arraysize(always_flags)); arraysize(always_flags));
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// Test for conflicting variable bindings. // Test for conflicting variable bindings.
// Flags: --no-legacy-const --harmony-sloppy // Flags: --no-legacy-const --harmony-sloppy --harmony-sloppy-let
function CheckException(e) { function CheckException(e) {
var string = e.toString(); var string = e.toString();
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-computed-property-names // Flags: --harmony-computed-property-names
// Flags: --no-legacy-const --harmony-sloppy // Flags: --no-legacy-const --harmony-sloppy --harmony-sloppy-let
// Test that we throw early syntax errors in harmony mode // Test that we throw early syntax errors in harmony mode
// when using an immutable binding in an assigment or with // when using an immutable binding in an assigment or with
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --no-legacy-const --harmony-sloppy // Flags: --no-legacy-const --harmony-sloppy --harmony-sloppy-let
function props(x) { function props(x) {
var array = []; var array = [];
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --no-legacy-const --harmony-sloppy // Flags: --no-legacy-const --harmony-sloppy --harmony-sloppy-let
// We want to test the context chain shape. In each of the tests cases // We want to test the context chain shape. In each of the tests cases
// below, the outer with is to force a runtime lookup of the identifier 'x' // below, the outer with is to force a runtime lookup of the identifier 'x'
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax // Flags: --allow-natives-syntax
// Flags: --no-legacy-const --harmony-sloppy // Flags: --no-legacy-const --harmony-sloppy --harmony-sloppy-let
// Check that the following functions are optimizable. // Check that the following functions are optimizable.
var functions = [ f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, var functions = [ f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14,
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
// Test let declarations in various settings. // Test let declarations in various settings.
// Flags: --no-legacy-const --harmony-sloppy // Flags: --no-legacy-const --harmony-sloppy --harmony-sloppy-let
// Global // Global
let x; let x;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-sloppy --no-legacy-const // Flags: --harmony-sloppy --no-legacy-const --harmony-sloppy-let
// Test temporal dead zone semantics of let bound variables in // Test temporal dead zone semantics of let bound variables in
// function and block scopes. // function and block scopes.
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --harmony-sloppy --no-legacy-const // Flags: --allow-natives-syntax --harmony-sloppy --no-legacy-const --harmony-sloppy-let
// Test functionality of block scopes. // Test functionality of block scopes.
// Hoisting of var declarations. // Hoisting of var declarations.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --min-preparse-length=0 // Flags: --min-preparse-length=0
// Flags: --no-legacy-const --harmony-sloppy // Flags: --no-legacy-const --harmony-sloppy --harmony-sloppy-let
let xxx = 1; let xxx = 1;
let f = undefined; let f = undefined;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment