diff --git a/deps/v8/src/parsing/parser.cc b/deps/v8/src/parsing/parser.cc index 509ca9322666..112bbc623d69 100644 --- a/deps/v8/src/parsing/parser.cc +++ b/deps/v8/src/parsing/parser.cc @@ -947,7 +947,7 @@ void Parser::ParseWrapped(Isolate* isolate, ParseInfo* info, FunctionLiteral* function_literal = ParseFunctionLiteral(function_name, location, kSkipFunctionNameCheck, FunctionKind::kNormalFunction, kNoSourcePosition, - FunctionSyntaxKind::kWrapped, LanguageMode::kSloppy, + FunctionSyntaxKind::kWrapped, info->language_mode(), arguments_for_wrapped_function); Statement* return_statement = diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js index 5b090279621f..d0c0c9c16f62 100644 --- a/test/parallel/test-cli-eval.js +++ b/test/parallel/test-cli-eval.js @@ -30,8 +30,10 @@ if (module !== require.main) { const common = require('../common'); const assert = require('assert'); const child = require('child_process'); +const fs = require('fs'); const path = require('path'); const fixtures = require('../common/fixtures'); +const tmpdir = require('../common/tmpdir'); if (process.argv.length > 2) { console.log(process.argv.slice(2).join(' ')); @@ -149,6 +151,29 @@ child.exec(...common.escapePOSIXShell`"${process.execPath}" --use-strict -p proc assert.strictEqual(stderr, ''); })); +// Regression test for https://github.com/nodejs/node/issues/30039. +{ + tmpdir.refresh(); + const scriptPath = tmpdir.resolve('use-strict.js'); + fs.writeFileSync(scriptPath, 'undeclared = 1;'); + + common.spawnPromisified(process.execPath, [scriptPath]) + .then(common.mustCall(({ stdout, stderr, code, signal }) => { + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, ''); + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); + })); + + common.spawnPromisified(process.execPath, ['--use-strict', scriptPath]) + .then(common.mustCall(({ stdout, stderr, code, signal }) => { + assert.strictEqual(stdout, ''); + assert.match(stderr, /ReferenceError: undeclared is not defined/); + assert.strictEqual(code, 1); + assert.strictEqual(signal, null); + })); +} + // Regression test for https://github.com/nodejs/node/issues/3574. { const emptyFile = fixtures.path('empty.js');