sanctuary-js / sanctuary-def

Run-time type system for JavaScript
MIT License
293 stars 23 forks source link

Function implementation names should equal def's name argument #214

Closed mfidemraizer closed 5 years ago

mfidemraizer commented 6 years ago

Say you've defined a function as follows:

const f = x => y => x  + y

When one debugs and prints out f.name, console outs f too.

In the other hand, once you wrap a given named function using def, JavaScript runtimes won't automatically set the function name anymore and probably one will get an empty string in place of f.name.

This change is important since functions typed with def aren't anonymous anymore and they can be seen in a given stack trace after some throw. If typing isn't enough to locate where's the issue, at least one may be able to review the stack trace and follow the code with this extra detail.

davidchambers commented 5 years ago

I like the idea but not the implementation. Please submit another pull request if you would like to do so.