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

instanceof JsObject returns false functions #9347

Closed
gkdn opened this issue May 20, 2016 · 8 comments
Closed

instanceof JsObject returns false functions #9347

gkdn opened this issue May 20, 2016 · 8 comments
Assignees
Milestone

Comments

@gkdn
Copy link
Contributor

gkdn commented May 20, 2016

instanceof JsObject returns false functions although instanceof Object returns true.
This because it is special cased to be translated as typeof == 'object' which doesn't return true for all cases.

@gkdn gkdn added this to the 2.8 milestone May 20, 2016
@rluble
Copy link
Contributor

rluble commented May 20, 2016

should it be typeof == 'object' || typeof == 'function'?

@gkdn
Copy link
Contributor Author

gkdn commented May 20, 2016

null and undefined should cast as well but instanceof those should fail.
I need to think more about it.

@rluble
Copy link
Contributor

rluble commented May 20, 2016

Isn't that the current behaviour for null/undefined?

On Thu, May 19, 2016 at 7:12 PM, Goktug Gokdogan notifications@github.com
wrote:

null and undefined should cast as well but instanceof those should fail.
I need to think more about it.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#9347 (comment)

@gkdn
Copy link
Contributor Author

gkdn commented May 20, 2016

Might be, might be not. Needs to be verified since typeof null is 'object' while typeof undefined is 'undefined' so I would be surprised if the current implementation works correctly at the same time for both scenarios.

@rluble
Copy link
Contributor

rluble commented May 20, 2016

Yes. instanceof JsObject will return true for null and false for undefined.
Tricky, tricky, tricky.

On Thu, May 19, 2016 at 7:22 PM, Goktug Gokdogan notifications@github.com
wrote:

Might be, might be not. Needs to be verified since typeof null is 'object'
while typeof undefined is 'undefined' so I would be surprised if the
current implementation works correctly at the same time for both scenarios.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#9347 (comment)

@dankurka
Copy link
Member

I am guessing this needs to be in 2.8 correct?

What is left to do here? Go through all cast scenarios in Casts.java and verify that the work as intended?

Who is going to do that work?

@gkdn
Copy link
Contributor Author

gkdn commented Jun 14, 2016

We need update the test cases esp. around handling of null and primitives and functions.
The behavior should be like o != null && (typeof == objectt || typeof == function) - needs to be verified.

@rluble rluble assigned rluble and unassigned gkdn Jun 15, 2016
@rluble
Copy link
Contributor

rluble commented Jun 15, 2016

Code is up for review at https://gwt-review.googlesource.com/#/c/15173

@rluble rluble closed this as completed Jun 15, 2016
hpehl pushed a commit to hpehl/gwt that referenced this issue Jun 16, 2016
Bug: gwtproject#9347
Bug-Link: http://github.com/gwtproject/gwt/issues/9347
Change-Id: I4996be8f0b347b696f27763669550cf739729df7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants