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

parse error with unary operators +-*/% #21

Open
lateau opened this issue Mar 7, 2012 · 2 comments
Open

parse error with unary operators +-*/% #21

lateau opened this issue Mar 7, 2012 · 2 comments

Comments

@lateau
Copy link
Contributor

lateau commented Mar 7, 2012

our parser does not allows something weird but ruby does:

------1

  •     -1
    

actually, ruby op are works different ways in some cases.
in this case it will call method -@ of 1(Integer).

but our parser cannot handle these weird case.
because it would not call the method or do something near behavior.

we need to try proto prefix or some other way.

@leto
Copy link
Member

leto commented Mar 7, 2012

Which implementations and versions of Ruby have you verified this on? I assume that whatever MRI does is "right" and everybody else is wrong or at least inconsistent.

@lateau
Copy link
Contributor Author

lateau commented Mar 8, 2012

on 1.9.3p0 / 1.9.3p125 / trunk

Ruby Draft Specification defines these unary op in general ways(see 11.4.3) and no descriptions about above weird case.
I guess it may be possible. The specification says "the value of the unary-expression is the resulting value of the invocation". And if the resulting value also has -@ method, it will be evaluated again.

you would like to look around rule "args" on parse.y.

see also lastest ruby draft spec:
http://www.ipa.go.jp/osc/english/ruby/

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

2 participants