Skip to content

Cast to null is not a cast #103

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

Closed
czosel opened this issue Dec 26, 2017 · 4 comments
Closed

Cast to null is not a cast #103

czosel opened this issue Dec 26, 2017 · 4 comments
Assignees

Comments

@czosel
Copy link
Collaborator

czosel commented Dec 26, 2017

Now that the PR #102 is merged, I have another question concerning casts. I noticed that (unset) $foo is parsed as an unset node instead of a cast node with type unset. While this is workable for the prettier integration, i still found it a bit confusing - especially because the difference bettween the unset cast and a regular call like unset($foo) is just that the first one has a single node in arguments, while the second one has a list.
Thanks in advance 😄

@ichiriac ichiriac self-assigned this Dec 26, 2017
@ichiriac
Copy link
Member

ichiriac commented Dec 26, 2017

Noooo, it's not good to prettier, it's a real BUG, I may did not pay enough attention on it !!!

Example #2 Using (unset) casting

(unset) casting is often confused with the unset() function. (unset) casting serves 
only as a NULL-type cast, for completeness. It does not alter the variable it's casting.

from : http://php.net/manual/en/function.unset.php

Here a testing code :
https://astexplorer.net/#/gist/c5098fd3b19f3c0da9de29986aa553d9/faff581d39f825cf78111278d0048055a3dd031b

The two nodes are the same, you can see the cast as the same way to say NULL (just a synonym), it's just useless, so that's a critical bug.

@czosel
Copy link
Collaborator Author

czosel commented Dec 26, 2017

Alright, then i'll happily scrap the workaround i had implemented locally! 😄

@ichiriac
Copy link
Member

thanks @czosel, it's now fixed

@czosel
Copy link
Collaborator Author

czosel commented Dec 26, 2017

That was quick! Thanks a lot 👍

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