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

lateau opened this Issue Mar 7, 2012 · 2 comments


None yet

2 participants

lateau commented Mar 7, 2012

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.

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 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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment