nodejs/deps/v8/test/message/fail/stack-trace-method-name-renaming.js

13 lines
391 B
JavaScript
Raw Permalink Normal View History

deps: V8: cherry-pick ad21d212fc14 Original commit message: Preserve "proper method names" as-is in error.stack. This changes the logic for generating method names in `error.stack` to prepend an inferred type name only when the function name is a valid ECMAScript identifiers and does not equal the inferred type name, to (1) give developers more control over the exact name shown in `error.stack`, as well as (2) avoid confusion in the presence of renaming of local variables. Previously we'd leave the function name as-is if it was prefixed by the inferred type name, but that condition is unnecessarily strict, and led to a bunch of inconsistencies around special names like `<instance_member_initializer>` where this dynamic approached often prefixed it with the correct type name, but also sometimes got it wrong and prepended `Object.`, which is very unfortunate and misleading. Specifically for these special names, we'll add logic later in the parser to infer a useful (complete) name. The design doc (https://bit.ly/devtools-method-names-in-stack-traces) contains more background and examples of why we do this change. Doc: https://bit.ly/devtools-method-names-in-stack-traces Fixed: chromium:1294619 Bug: chromium:1283435 Change-Id: Ib8b528ba25255dcd07e9d11044c562c11d699bcb Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3565724 Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/main@{#79748} Refs: https://github.com/v8/v8/commit/ad21d212fc147a723f9d751e501fdeb576656261 PR-URL: https://github.com/nodejs/node/pull/42657 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
2022-04-12 16:30:41 +02:00
// Copyright 2022 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.
// Check that the dynamic type name ('A') is not prepended to the inferred
// method name ('C.a') in error.stack output.
const A = function() {};
const C = A;
C.prototype.a = function() {
throw new Error;
};
(new A).a();