On Wed, Aug 30, 2023 at 11:53 AM Xavier Noria <fxn@hashref.com> wrote:

> (a, b) does not play the role of an expression, right? Similarly, in your examples with puts,
>
>     puts(...)
>
> is parsed as puts + the argument list of the call. Again, not an expression. In an argument list, a semicolon does not make sense, it is a syntax error.

My example had a space between puts and '('.  The documentation says:
"If you put a space between the method name and opening parenthesis,
you do not need two sets of parentheses." but 'puts (:ignore; :x)'
raises an error.

Oh, the space, right.

    p (1 if true), (2 if false)

passes two arguments to p just fine.

The specs for this are here (an authoritative source when documentation is lacking), and I cannot give you an answer to what you found without guessing. It could even be a bug in the parser, because I don't quite see why is a ternary operator parsed, but not an expression with ;.

I don't know.

I have opened https://github.com/ruby/spec/pull/1063.

If it goes in, it is intentional, but it is not related to the syntax for arbitrary expressions. I exchanged impressions with Kevin Newton, and making parantheses optional in that corner of the grammar is special-cased for single statements.

Let's see what we find out!