From: bughit.github@...
Date: 2021-07-19T19:56:32+00:00
Subject: [ruby-core:104648] [Ruby master Feature#18040] Why should `foo(1 if	true)` be an error?

Issue #18040 has been updated by bughit (bug hit).


jeremyevans0 (Jeremy Evans) wrote in #note-4:
> 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

You can call it a statement all you want but if it produces a value, its an expression. And it does produce produce a value.

Here's the description of method return from "the ruby programming language" book:

> If a method terminates normally, then
the value of the method invocation expression is the value of the last expression evaluated
within the method body.

the last expression in my example is `1 if false` with no parens



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

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