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

Function.toString() omits function name in output #9543

Closed
luckydye opened this issue Mar 21, 2024 · 1 comment
Closed

Function.toString() omits function name in output #9543

luckydye opened this issue Mar 21, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@luckydye
Copy link

luckydye commented Mar 21, 2024

What version of Bun is running?

1.0.33+9e91e137f

What platform is your computer?

Darwin 23.2.0 arm64 arm

What steps can reproduce the bug?

Run:

echo "function myFunction() {
  console.log('Test function');
  if (true) {
    return 1;
  }
}
console.log('export ' + myFunction.toString());" > test.js && bun test.js

What is the expected behavior?

Expected ouput:

export function myFunction() {
  console.log('Test function');
  if (true) {
    return 1;
  }
}

What do you see instead?

export function() {
  console.log("Test function");
  return 1;
}

Additional information

I came across this issue when trying to run @vitejs/plugin-vue-jsx which relies on Function.toString to include the name for export, like in my example above.

@Electroid
Copy link
Contributor

Duplicate of #3248

@Electroid Electroid marked this as a duplicate of #3248 Mar 21, 2024
@Electroid Electroid closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants