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

Unary expressions like `+++++++---------++++++1` shouldn't be valid #955

Closed
juliusv opened this Issue Aug 3, 2015 · 9 comments

Comments

Projects
None yet
3 participants
@juliusv
Copy link
Member

juliusv commented Aug 3, 2015

E.g. +++++++---------++++++1 returns -1. Guess it should be a parse error?

@juliusv

This comment has been minimized.

Copy link
Member Author

juliusv commented Aug 3, 2015

@juliusv

This comment has been minimized.

Copy link
Member Author

juliusv commented Aug 3, 2015

Reason is the recursion here:

e := p.unaryExpr()

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Aug 3, 2015

Yes. This is very much intended and valid. Why would this be a parsing error?

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Aug 3, 2015

In that case, why is -If a parse error? It's not currently documented that we have unary operators.

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Aug 3, 2015

-If is a runtime panic based on an unrelated bug. It's fixed in #954.
Unary expressions exist for number literals. Applying it to a vector or matrix errors "expected type scalar in unary expression, got vector". This is no new behavior.

@juliusv

This comment has been minimized.

Copy link
Member Author

juliusv commented Aug 3, 2015

Ok yeah, though Go, JS, and some other languages don't allow this notation, Python seemingly does. And you can make a case for that it makes sense. So fine to close this from my side then.

@juliusv

This comment has been minimized.

Copy link
Member Author

juliusv commented Aug 3, 2015

(but yeah, it might be cool do allow -foo as well)

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Aug 3, 2015

Yes, I'll open a separate issue for that.

@fabxc fabxc closed this Aug 3, 2015

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 24, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.