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
feat: add Object.hasOwn as pure function #4482
Conversation
@lukastaegert I noticed I thought a pure function is one without side effects, e.g. |
Codecov Report
@@ Coverage Diff @@
## master #4482 +/- ##
=======================================
Coverage 98.75% 98.75%
=======================================
Files 205 205
Lines 7327 7327
Branches 2080 2080
=======================================
Hits 7236 7236
Misses 33 33
Partials 58 58
Continue to review full report at Codecov.
|
You are right, with the current simple logic all of them should not be marked as pure. To solve this in a good way, we would need a way to specify a function iterates the keys of its argument and is pure if there are no own property getters. The global logic is very dumb at the moment as it only understands a single flag—
Compare this with the much more advanced logic for builtin prototypes (which ideally should be merged with the globals logic at some point): Lines 7 to 10 in 8de6943
Here we know a return value and can specify that an argument is called (but do not know about iterating keys because that was not needed). So we could add a flag that says something like callOptions.args[0].hasEffectsWhenAccessedAtPath(UNKNOWN_PATH, context) |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description