Skip to content

Commit

Permalink
src: disable harmony object literals
Browse files Browse the repository at this point in the history
Per the discussion in nodejs#272, upstream
V8 has disabled Harmony object literals for the time being.  Do the
same for feature parity.

PR-URL: nodejs#272
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Domenic Denicola <[email protected]>
  • Loading branch information
bnoordhuis committed Jan 9, 2015
1 parent a2751e3 commit 4e58211
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions test/parallel/test-v8-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] }');

0 comments on commit 4e58211

Please sign in to comment.