-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store object call properties in internal slot
Summary: Before this change, callable objects, declared classes, and interfaces all stored the callable signature in a specially-named property `$call`. It's perfectly legal to have a property with that name, however unlikely, so this representation has inherent badness. Furthermore, storing the callable signature in the propmap means that it interacts with prototype lookup, but at runtime a callable signature can not be inherited through the prototype chain. Consider the following program, which is an error at runtime, but which Flow accepts as valid. ``` function f() {} var o = Object.create(f); o(); // TypeError: o is not a function ``` Lastly, users have "figured out" this behavior and have started to actually define objects with an explicit `$call` property instead of using the intended syntax. Sometimes this capability is actually useful, specifically when the desired callable signature is not a function type. Reviewed By: panagosg7 Differential Revision: D8041565 fbshipit-source-id: 0f760cdf82b6e229a3c5db0c2e81a2331c7a2de1
- Loading branch information
1 parent
73df001
commit b9db648
Showing
13 changed files
with
288 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.