[#104481] [Ruby master Feature#18020] Introduce `IO::Buffer` for fiber scheduler. — samuel@...

Issue #18020 has been reported by ioquatix (Samuel Williams).

31 messages 2021/07/03

[#104492] [Ruby master Bug#18022] Spec errors for rbconfig/unicode_[emoji_]version_spec: Using Ruby 2.7 even when on Ruby 3.1 — duerst@...

Issue #18022 has been reported by duerst (Martin Dst).

8 messages 2021/07/04

[#104552] [Ruby master Feature#18033] Time.new to parse a string — nobu@...

Issue #18033 has been reported by nobu (Nobuyoshi Nakada).

26 messages 2021/07/09

[#104560] [Ruby master Bug#18035] Introduce general module for immutable by default. — samuel@...

Issue #18035 has been reported by ioquatix (Samuel Williams).

41 messages 2021/07/09

[#104629] [Ruby master Misc#18039] DevelopersMeeting20210819Japan — mame@...

Issue #18039 has been reported by mame (Yusuke Endoh).

11 messages 2021/07/16

[#104643] [Ruby master Bug#18040] Why should `foo(1 if true)` be an error? — bughit.github@...

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

10 messages 2021/07/19

[#104665] [Ruby master Feature#18042] YARV code optimization — motoroller95@...

Issue #18042 has been reported by motoroller (Iskandar Gohar).

11 messages 2021/07/23

[#104692] [Ruby master Bug#18048] Thread#join can break with fiber scheduler unblock fails or blocks. — samuel@...

Issue #18048 has been reported by ioquatix (Samuel Williams).

10 messages 2021/07/27

[#104723] [Ruby master Bug#18054] No rule to make target 'thread_fd_close.c', needed by 'thread_fd_close.o' — duerst@...

Issue #18054 has been reported by duerst (Martin Dst).

8 messages 2021/07/29

[ruby-core:104649] [Ruby master Feature#18040] Why should `foo(1 if true)` be an error?

From: merch-redmine@...
Date: 2021-07-19 20:41:54 UTC
List: ruby-core #104649
Issue #18040 has been updated by jeremyevans0 (Jeremy Evans).


bughit (bug hit) wrote in #note-5:
> 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 a value.

The reason that `foo(1 if false)` is a syntax error is due to a parsing failure.  The parser considers it a statement (`stmt`) and not an expression.  What the parser considers statements can still return values in Ruby.

In any case, the reason for the issue remains the same.  The parser doesn't allow a statement (`stmt`) to be used directly as a method argument.  You have to wrap it in parentheses to use it as a method argument.  Trying to support a `stmt` used directly as a method argument (`arg`), results in 132 shift/reduce conflicts and 2056 reduce/reduce conflicts in the parser. I doubt there is any way to support it as a general method argument.  As I mentioned it may be possible to get it to work in only the single argument case by special casing it.  However, I couldn't get that to work without shift/reduce conflicts.  Maybe @nobu would have more luck.  Even then, we would have to decide if we want to support that, because it would result in inconsistent syntax, since `foo(1 if false)` would be allowed, but `foo(1 if false, 2)` (the multiple argument case) would not. 

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

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

In This Thread