From 3a648b7e6262a5a467a5f237e0dd37e2d0c0f8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 9 Jan 2018 13:26:12 +0100 Subject: [PATCH] deps: cherry-pick c3458a8 from upstream V8 Original commit message: [parser] Add new FunctionNameInferrer state before parsing param Create new state before parsing FormalParameter because we don't want to use any of the parameters as an inferred function name. Previously the stacktrace was: test.js:3: Error: boom throw new Error('boom'); ^ Error: boom at param (test.js:3:11) at test.js:4:5 at test.js:6:3 The stacktrace with this patch: test.js:3: Error: boom throw new Error('boom'); ^ Error: boom at test.js:3:11 at test.js:4:5 at test.js:6:3 Bug: v8:6822, v8:6513 Change-Id: Ifbadc660fc4e85248af405acd67c025f11662bd4 Reviewed-on: https://chromium-review.googlesource.com/742657 Reviewed-by: Adam Klein Commit-Queue: Sathya Gunasekaran Cr-Commit-Position: refs/heads/master@{#49042} PR-URL: https://github.com/nodejs/node/pull/18059 Closes: https://github.com/nodejs/node/issues/15386 Fixes: https://github.com/nodejs/node/issues/15386 Refs: https://github.com/v8/v8/commit/c3458a86722d735ef4c4e31f9bcaa966e5093e47 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: Franziska Hinkelmann --- deps/v8/include/v8-version.h | 2 +- deps/v8/src/parsing/parser-base.h | 1 + deps/v8/test/message/fail/func-name-inferrer-arg-1.js | 10 ++++++++++ deps/v8/test/message/fail/func-name-inferrer-arg-1.out | 8 ++++++++ deps/v8/test/message/fail/func-name-inferrer-arg.js | 10 ++++++++++ deps/v8/test/message/fail/func-name-inferrer-arg.out | 7 +++++++ 6 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 deps/v8/test/message/fail/func-name-inferrer-arg-1.js create mode 100644 deps/v8/test/message/fail/func-name-inferrer-arg-1.out create mode 100644 deps/v8/test/message/fail/func-name-inferrer-arg.js create mode 100644 deps/v8/test/message/fail/func-name-inferrer-arg.out diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 2cea4b875d452c..3d24701f5ef608 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 6 #define V8_MINOR_VERSION 1 #define V8_BUILD_NUMBER 534 -#define V8_PATCH_LEVEL 50 +#define V8_PATCH_LEVEL 51 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/parsing/parser-base.h b/deps/v8/src/parsing/parser-base.h index 104e36ea9347ce..81e864c146da4d 100644 --- a/deps/v8/src/parsing/parser-base.h +++ b/deps/v8/src/parsing/parser-base.h @@ -3573,6 +3573,7 @@ void ParserBase::ParseFormalParameter(FormalParametersT* parameters, // BindingElement[?Yield, ?GeneratorParameter] bool is_rest = parameters->has_rest; + FuncNameInferrer::State fni_state(fni_); ExpressionT pattern = ParsePrimaryExpression(CHECK_OK_CUSTOM(Void)); ValidateBindingPattern(CHECK_OK_CUSTOM(Void)); diff --git a/deps/v8/test/message/fail/func-name-inferrer-arg-1.js b/deps/v8/test/message/fail/func-name-inferrer-arg-1.js new file mode 100644 index 00000000000000..6c28367d921433 --- /dev/null +++ b/deps/v8/test/message/fail/func-name-inferrer-arg-1.js @@ -0,0 +1,10 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(function (param = function() { throw new Error('boom') }) { + (() => { + param(); + })(); + +})(); diff --git a/deps/v8/test/message/fail/func-name-inferrer-arg-1.out b/deps/v8/test/message/fail/func-name-inferrer-arg-1.out new file mode 100644 index 00000000000000..3c19121a0a6efa --- /dev/null +++ b/deps/v8/test/message/fail/func-name-inferrer-arg-1.out @@ -0,0 +1,8 @@ +*%(basename)s:5: Error: boom +(function (param = function() { throw new Error('boom') }) { + ^ +Error: boom + at param (*%(basename)s:5:39) + at *%(basename)s:7:5 + at *%(basename)s:8:5 + at *%(basename)s:10:3 \ No newline at end of file diff --git a/deps/v8/test/message/fail/func-name-inferrer-arg.js b/deps/v8/test/message/fail/func-name-inferrer-arg.js new file mode 100644 index 00000000000000..3fcd044b9b1831 --- /dev/null +++ b/deps/v8/test/message/fail/func-name-inferrer-arg.js @@ -0,0 +1,10 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(function (param) { + (() => { + throw new Error('boom'); + })(); + +})(); diff --git a/deps/v8/test/message/fail/func-name-inferrer-arg.out b/deps/v8/test/message/fail/func-name-inferrer-arg.out new file mode 100644 index 00000000000000..06e001d1d5e641 --- /dev/null +++ b/deps/v8/test/message/fail/func-name-inferrer-arg.out @@ -0,0 +1,7 @@ +*%(basename)s:7: Error: boom + throw new Error('boom'); + ^ +Error: boom + at *%(basename)s:7:11 + at *%(basename)s:8:5 + at *%(basename)s:10:3 \ No newline at end of file