oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.14k stars 2.76k forks source link

Function.constructor.toString() output includes newLines #12966

Open ayZagen opened 3 months ago

ayZagen commented 3 months ago

What version of Bun is running?

1.1.21+70ca2b76c

What platform is your computer?

Linux 5.15.153.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

const a = function() {
  console.log( 'test' );
};

console.log( a.constructor.toString() );

Bun Output:

function Function() {
    [native code]
}

NodeJs & Browser Output:

function Function() { [native code] }

What is the expected behavior?

The output must be the same for javascript environments. This could lead to bugs in existing projects which checks functions as value.constructor.toString() === 'function Function() { [native code] }'

ayZagen commented 3 months ago

Link to ES spec https://tc39.es/Function-prototype-toString-revision/#proposal-sec-function.prototype.tostring

@dszymon Can you elaborate the thumbs down?