Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CallSite.prototype.getFunctionName #813

Open
bnoordhuis opened this issue Jan 10, 2025 · 3 comments
Open

Improve CallSite.prototype.getFunctionName #813

bnoordhuis opened this issue Jan 10, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@bnoordhuis
Copy link
Contributor

Error.prepareStackTrace = function(s, cs) {
    print(cs[0].getFunctionName())
    return 42
}
try {
    eval("bad code")
} catch (_) {
    // ignore
}

Outputs:

$ qjs --script t.js 
null
<eval>

That is, the first call site has null as the function name. It'd be infinitesimally nicer if that also returned e.g. <eval>.

@bnoordhuis bnoordhuis added the enhancement New feature or request label Jan 10, 2025
@saghul
Copy link
Contributor

saghul commented Jan 10, 2025

Node seems to do the same?

Error.prepareStackTrace = function(s, cs) {
    cs.forEach(csi => {
        console.log(csi.getFunctionName())
    });
    return 42
}
try {
    eval("bad code")
} catch (e) {
    console.log(e);
    // ignore
}
node ./t.cjs
null
Module._compile
Module._extensions..js
Module.load
Module._load
executeUserEntryPoint
null
[42]

@bnoordhuis
Copy link
Contributor Author

Node seems to do the same?

Meaning we can do better :)

@saghul
Copy link
Contributor

saghul commented Jan 11, 2025

Haha true!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants