tc39 / proposal-error-stacks

ECMAScript Proposal, specs, and reference implementation for Error.prototype.stack / System.getStack
https://tc39.github.io/proposal-error-stacks/
MIT License
170 stars 13 forks source link

Relation with Tail Call Elimination #23

Closed claudepache closed 5 years ago

claudepache commented 5 years ago

When frames are elided because of Tail Call Elimination, should they also be omitted from the stack trace? Experience with JSC shows that it is indeed the case for them; here is a testcase:

(function foo() { 
    "use strict"; 
    function bar() { return new Error }
    return bar()
})().stack
mk-pmb commented 5 years ago

What were the pros/cons that lead to "that it is indeed the case for them"? The example is a special case in that

ljharb commented 5 years ago

The feature you’re referring to is Proper Tail Calls; since this proposal only specifies the format of the stack, and not its contents, it does not interact with PTC.

However, this proposal does build a foundation on which a followup proposal could specify the contents.