From 4e58211bb7f638b689e5e8e407b70b3c29be952f Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 9 Jan 2015 17:03:21 +0100 Subject: [PATCH] src: disable harmony object literals Per the discussion in https://github.com/iojs/io.js/pull/272, upstream V8 has disabled Harmony object literals for the time being. Do the same for feature parity. PR-URL: https://github.com/iojs/io.js/pull/272 Reviewed-By: Colin Ihrig Reviewed-By: Domenic Denicola --- src/node.cc | 2 ++ test/parallel/test-v8-features.js | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/node.cc b/src/node.cc index 0ff8aa21b15..e390058567d 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3360,6 +3360,8 @@ void Init(int* argc, // again when we upgrade. V8::SetFlagsFromString("--noharmony_classes", sizeof("--noharmony_classes") - 1); + V8::SetFlagsFromString("--noharmony_object_literals", + sizeof("--noharmony_object_literals") - 1); #if defined(NODE_V8_OPTIONS) // Should come before the call to V8::SetFlagsFromCommandLine() diff --git a/test/parallel/test-v8-features.js b/test/parallel/test-v8-features.js index 50757264ae3..aac9de4a29c 100644 --- a/test/parallel/test-v8-features.js +++ b/test/parallel/test-v8-features.js @@ -19,3 +19,13 @@ var args = ['--harmony_classes', '--use_strict', '-p', 'class C {}']; var cp = spawnSync(process.execPath, args); assert.equal(cp.status, 0); assert.equal(cp.stdout.toString('utf8').trim(), '[Function: C]'); + +// Now do the same for --harmony_object_literals. +assert.throws(function() { eval('({ f() {} })'); }, SyntaxError); +v8.setFlagsFromString('--harmony_object_literals'); +eval('({ f() {} })'); + +var args = ['--harmony_object_literals', '-p', '({ f() {} })']; +var cp = spawnSync(process.execPath, args); +assert.equal(cp.status, 0); +assert.equal(cp.stdout.toString('utf8').trim(), '{ f: [Function: f] }');