Forum: Ruby-dev [ruby-trunk - Bug #10653] do-end block in ternary operator is syntax error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2014-12-26 09:01
(Received via mailing list)
Issue #10653 has been updated by Nobuyoshi Nakada.

Related to Feature #4276: Allow use of quotes in symbol syntactic sugar
for hashes added

----------------------------------------
Bug #10653: do-end block in ternary operator is syntax error
https://bugs.ruby-lang.org/issues/10653#change-50642

* Author: Shinta Koyanagi
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: syntax
* Target version:
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
- For example

```
ruby -v -e 'true ? 1.tap do |n| p n end : 0'
```

- Result by 2.1.5

```
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
1
```

- Result by 2.2.0

```
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
-e:1: syntax error, unexpected keyword_do_cond, expecting ':'
true ? 1.tap do |n| p n end : 0
               ^
-e:1: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{'
or '('
true ? 1.tap do |n| p n end : 0
                       ^
```
This topic is locked and can not be replied to.