Issue #18040 has been updated by jeremyevans0 (Jeremy Evans).


bughit (bug hit) wrote in #note-2:
> jeremyevans0 (Jeremy Evans) wrote in #note-1:
> > `1 if true` is a statement and not an expression
> 
> `1 if true` is an expression (as pretty much everything in ruby) whose value is nil, if the condition is false, else the modified subexpression. Parens don't turn it into an expression, it already is one.

You may want to read the definition of `stmt` in parse.y, particularly this part: https://github.com/ruby/ruby/blob/eed5e8f796ab18e2e0a436dab83e35504ae3ded0/parse.y#L1481

----------------------------------------
Feature #18040: Why should `foo(1 if true)` be an error?
https://bugs.ruby-lang.org/issues/18040#change-92956

* Author: bughit (bug hit)
* Status: Open
* Priority: Normal
----------------------------------------
There's no ambiguity here that should require another set of parens `foo((1 if true))`



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>