Skip to content

Commit c3458a8

Browse files
gsathyaCommit Bot
authored andcommitted
[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 <[email protected]> Commit-Queue: Sathya Gunasekaran <[email protected]> Cr-Commit-Position: refs/heads/master@{#49042}
1 parent c690f54 commit c3458a8

5 files changed

Lines changed: 36 additions & 0 deletions

File tree

src/parsing/parser-base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3710,6 +3710,7 @@ void ParserBase<Impl>::ParseFormalParameter(FormalParametersT* parameters,
37103710
// BindingElement[?Yield, ?GeneratorParameter]
37113711
bool is_rest = parameters->has_rest;
37123712

3713+
FuncNameInferrer::State fni_state(fni_);
37133714
ExpressionT pattern = ParsePrimaryExpression(CHECK_OK_CUSTOM(Void));
37143715
ValidateBindingPattern(CHECK_OK_CUSTOM(Void));
37153716

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2017 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
(function (param = function() { throw new Error('boom') }) {
6+
(() => {
7+
param();
8+
})();
9+
10+
})();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*%(basename)s:5: Error: boom
2+
(function (param = function() { throw new Error('boom') }) {
3+
^
4+
Error: boom
5+
at param (*%(basename)s:5:39)
6+
at *%(basename)s:7:5
7+
at *%(basename)s:8:5
8+
at *%(basename)s:10:3
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2017 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
(function (param) {
6+
(() => {
7+
throw new Error('boom');
8+
})();
9+
10+
})();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*%(basename)s:7: Error: boom
2+
throw new Error('boom');
3+
^
4+
Error: boom
5+
at *%(basename)s:7:11
6+
at *%(basename)s:8:5
7+
at *%(basename)s:10:3

0 commit comments

Comments
 (0)