Skip to content

Commit

Permalink
deps: cherry-pick c3458a8 from upstream V8
Browse files Browse the repository at this point in the history
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 <adamk@chromium.org>
    Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#49042}

PR-URL: #18060
Backport-PR-URL: #16413
Fixes: #15386
Refs: v8/v8@c3458a8
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
targos authored and gibfahn committed Feb 18, 2018
1 parent aae68d3 commit 2b84fa9
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deps/v8/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 6
#define V8_MINOR_VERSION 2
#define V8_BUILD_NUMBER 414
#define V8_PATCH_LEVEL 48
#define V8_PATCH_LEVEL 49

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/parsing/parser-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -3634,6 +3634,7 @@ void ParserBase<Impl>::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));

Expand Down
10 changes: 10 additions & 0 deletions deps/v8/test/message/fail/func-name-inferrer-arg-1.js
Original file line number Diff line number Diff line change
@@ -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();
})();

})();
8 changes: 8 additions & 0 deletions deps/v8/test/message/fail/func-name-inferrer-arg-1.out
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions deps/v8/test/message/fail/func-name-inferrer-arg.js
Original file line number Diff line number Diff line change
@@ -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');
})();

})();
7 changes: 7 additions & 0 deletions deps/v8/test/message/fail/func-name-inferrer-arg.out
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2b84fa9

Please sign in to comment.