Skip to content
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

Forbid static fields named caller #99

Open
onigoetz opened this issue Aug 3, 2015 · 1 comment
Open

Forbid static fields named caller #99

onigoetz opened this issue Aug 3, 2015 · 1 comment

Comments

@onigoetz
Copy link
Member

onigoetz commented Aug 3, 2015

This field is actually reserved ... So it would be good to forbid to use them.

You can assign a value to it, but the value isn't kept.

Just lost about two hours figuring out why a callback wasn't called :D

https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Function/caller

@npiguet
Copy link
Member

npiguet commented Aug 19, 2015

This is actually true for most non-writable fields that are part of the basic function properties. This includes both fields and methods. Some poperties are writable, some are not. Declaring static fields or static methods in the java class with the same name as any of those properties could have unexpected results.

Fields:
arguments, arity, caller, displayName, length, name, prototype

Methods:
apply(), bind(), call(), isGenerator(), toSource(), toString()

For some of them, we should probably throw an error (the ones that are not writable), for some others a warning might enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants