Skip to content


Subversion checkout URL

You can clone with
Download ZIP


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

lateau opened this Issue · 2 comments

2 participants


our parser does not allows something weird but ruby does:


  • -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.


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.


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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.