Bug 209571 - Function.length broken by Object.defineProperty and bind
Summary: Function.length broken by Object.defineProperty and bind
Status: RESOLVED DUPLICATE of bug 208497
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari Technology Preview
Hardware: Mac macOS 10.15
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-03-25 16:32 PDT by Andy Niccolai
Modified: 2020-03-25 19:07 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Niccolai 2020-03-25 16:32:50 PDT
With the release of Safari 13.1 (and also verified in 13.2 Technical Preview), Function.length always returns zero after binding arguments to a function that has a custom name defined.

Repro JS Fiddle: https://jsfiddle.net/7s9yop23/

Repro code

const originalFn = (a, b) => a + b;
Object.defineProperty(originalFn, 'name', {value: 'newFunctionName'});
const renamedAndBoundFn = originalFn.bind(undefined, 1);

// expected: 1
// actual: 0
renamedAndBoundFn.length
Comment 1 Radar WebKit Bug Importer 2020-03-25 18:03:41 PDT
<rdar://problem/60898213>
Comment 2 Yusuke Suzuki 2020-03-25 19:07:07 PDT
(In reply to Andy Niccolai from comment #0)
> With the release of Safari 13.1 (and also verified in 13.2 Technical
> Preview), Function.length always returns zero after binding arguments to a
> function that has a custom name defined.
> 
> Repro JS Fiddle: https://jsfiddle.net/7s9yop23/
> 
> Repro code
> 
> const originalFn = (a, b) => a + b;
> Object.defineProperty(originalFn, 'name', {value: 'newFunctionName'});
> const renamedAndBoundFn = originalFn.bind(undefined, 1);
> 
> // expected: 1
> // actual: 0
> renamedAndBoundFn.length

Thanks for reporting!
This is fixed in https://bugs.webkit.org/show_bug.cgi?id=208497 :)

*** This bug has been marked as a duplicate of bug 208497 ***