[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}
This commit is contained in:
parent
c690f54d95
commit
c3458a8672
@ -3710,6 +3710,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));
|
||||
|
||||
|
10
test/message/fail/func-name-inferrer-arg-1.js
Normal file
10
test/message/fail/func-name-inferrer-arg-1.js
Normal file
@ -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
test/message/fail/func-name-inferrer-arg-1.out
Normal file
8
test/message/fail/func-name-inferrer-arg-1.out
Normal file
@ -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
test/message/fail/func-name-inferrer-arg.js
Normal file
10
test/message/fail/func-name-inferrer-arg.js
Normal file
@ -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
test/message/fail/func-name-inferrer-arg.out
Normal file
7
test/message/fail/func-name-inferrer-arg.out
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user