-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Property extraction in form 'e.m' does not work for operators #24557
Comments
What is correct behavior? Should operators be extracted by e.m syntax as well as by e#m? |
According to the spec (16.32) o.m is an assignable expression with .. Therefore Section 16.18.7, on the other hand, explicitly talks about the operators. I believe this is working as intended (but will let Gilad close the bug). |
The grammar in question is:
Basically, the only thing allowed after a The closurization of operators can currently only be achieved using |
Ok, thank you for clarification. But it's not obvious. I think it makes sense to add to "16.18.1 Getter Access and Method Extraction" statement or, at least, non-normative section, describing that property extraction in form e.m doesn't work for operators |
Another place in the specification that should be changed "16.18.7 Ordinary Member Closurization" |
Generalized tear-offs are being removed (#27518) so I don't think we have to worry about cleaning up 16.18.7. For the |
Consider the following code:
This code doesn't work. Result is:
Bit if to replace
by
then it works well.
But where in the spec it is said that 'e.m' syntax should not extract operators?
According the specification (3-rd edition, June 2015) reads (16.18.1 Getter Access and Method Extraction):
"Evaluation of a property extraction i of the form e.m proceeds as follows: First, the expression e is evaluated to an object o. Let f be the result of looking up (16.15.1) method (10.1) m in o with respect to the current library L. If o is an instance of Type but e is not a constant type literal, then if f is a
method that forwards (9.1) to a static method, method lookup fails. If method lookup succeeds then i evaluates to the closurization of method f on object o"
According " 16.18.3 General Closurization"
"Evaluation of a property extraction i of the form e#m proceeds as follows:
...
If m is not a setter name, let f be the result of looking up method m
in o with respect to the current library L. If o is an instance of Type but e
is not a constant type literal, then if f is a method that forwards to a static
method, method lookup fails. If method lookup succeeds then i evaluates to the
closurization of method f on object o"
There are no any difference between these statements regarding operators. Either specification should be changed to clearly state that 'e.m' syntax should not extract operators either implementation should extract operators as well.
The text was updated successfully, but these errors were encountered: