• Benedikt Meurer's avatar
    Preserve "proper method names" as-is in error.stack. · ad21d212
    Benedikt Meurer authored
    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/+/3565724Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
    Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#79748}
    ad21d212