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

@var? does not check existence #2695

Closed
238855 opened this issue Feb 5, 2013 · 2 comments
Closed

@var? does not check existence #2695

238855 opened this issue Feb 5, 2013 · 2 comments

Comments

@238855
Copy link

238855 commented Feb 5, 2013

I expected @car? to behave the same as car?

car? compiles to typeof car !== "undefined" && car !== null;

but

@car? compiles to this.car != null;

Should it not compile to typeof this.car !== "undefined" && this.car !== null;? It is entirely possible that somebody could reference an undefined property of @ or this

@mehcode
Copy link

mehcode commented Feb 5, 2013

Throw the following into the compiler and it might make some more sense (remember @foo is really this.foo):

foo?
this.foo?
this?.foo
this.foo?
@foo?
@?foo # errors out with "Unexpected identifier" on both original and redux

I agree that @?foo should probably compile to this?.foo which compiles to:

if (typeof this !== "undefined" && this !== null) {
  this.foo;
}

@michaelficarra
Copy link
Collaborator

Duplicate of many, many other issues concerning the various existential operators. See #1631.

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

3 participants