* [ruby-dev:52164] [Ruby Bug#21608] 三項演算子と break を組み合わせると SyntaxError
@ 2025-09-17 0:25 ursm (Keita Urashima) - ruby-dev 経由
2025-09-17 0:53 ` [ruby-dev:52165] " kddnewton (Kevin Newton) - ruby-dev 経由
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: ursm (Keita Urashima) - ruby-dev 経由 @ 2025-09-17 0:25 UTC (permalink / raw)
To: ruby-dev; +Cc: ursm (Keita Urashima)
Issue #21608 has been reported by ursm (Keita Urashima).
----------------------------------------
Bug #21608: 三項演算子と break を組み合わせると SyntaxError
https://bugs.ruby-lang.org/issues/21608
* Author: ursm (Keita Urashima)
* Status: Open
* ruby -v: ruby 3.4.6 (2025-09-16 revision dbd83256b1) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
```
>> RUBY_VERSION
=> "3.4.5"
>> [1, 2].find {|i| i.even? ? break i : nil }
```
```
>> RUBY_VERSION
=> "3.4.6"
>> [1, 2].find {|i| i.even? ? break i : nil }
<internal:kernel>:168:in 'Kernel#loop': (irb):2: syntax error found (SyntaxError)
> 2 | ... i : nil }
| ^ unexpected local variable or method, expecting end-of-input
from /home/ursm/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/gems/irb-1.15.2/exe/irb:9:in '<top (required)>'
from /home/ursm/.local/share/mise/installs/ruby/3.4.6/bin/irb:25:in 'Kernel#load'
from /home/ursm/.local/share/mise/installs/ruby/3.4.6/bin/irb:25:in '<main>'
```
--
https://bugs.ruby-lang.org/
_______________________________________________
ruby-dev メーリングリスト -- ruby-dev@ml.ruby-lang.org
配信停止は ruby-dev-leave@ml.ruby-lang.org にメールをお送りください。
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-dev:52165] [Ruby Bug#21608] 三項演算子と break を組み合わせると SyntaxError
2025-09-17 0:25 [ruby-dev:52164] [Ruby Bug#21608] 三項演算子と break を組み合わせると SyntaxError ursm (Keita Urashima) - ruby-dev 経由
@ 2025-09-17 0:53 ` kddnewton (Kevin Newton) - ruby-dev 経由
2025-09-17 4:42 ` [ruby-dev:52166] " nobu (Nobuyoshi Nakada) - ruby-dev 経由
2025-09-17 5:33 ` [ruby-dev:52167] " Earlopain (Earlopain _) - ruby-dev 経由
2 siblings, 0 replies; 4+ messages in thread
From: kddnewton (Kevin Newton) - ruby-dev 経由 @ 2025-09-17 0:53 UTC (permalink / raw)
To: ruby-dev; +Cc: kddnewton (Kevin Newton)
Issue #21608 has been updated by kddnewton (Kevin Newton).
Assignee set to prism
Thank you for the report, I will get this fixed.
----------------------------------------
Bug #21608: 三項演算子と break を組み合わせると SyntaxError
https://bugs.ruby-lang.org/issues/21608#change-114646
* Author: ursm (Keita Urashima)
* Status: Open
* Assignee: prism
* ruby -v: ruby 3.4.6 (2025-09-16 revision dbd83256b1) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
```
>> RUBY_VERSION
=> "3.4.5"
>> [1, 2].find {|i| i.even? ? break i : nil }
```
```
>> RUBY_VERSION
=> "3.4.6"
>> [1, 2].find {|i| i.even? ? break i : nil }
<internal:kernel>:168:in 'Kernel#loop': (irb):2: syntax error found (SyntaxError)
> 2 | ... i : nil }
| ^ unexpected local variable or method, expecting end-of-input
from /home/ursm/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/gems/irb-1.15.2/exe/irb:9:in '<top (required)>'
from /home/ursm/.local/share/mise/installs/ruby/3.4.6/bin/irb:25:in 'Kernel#load'
from /home/ursm/.local/share/mise/installs/ruby/3.4.6/bin/irb:25:in '<main>'
```
--
https://bugs.ruby-lang.org/
_______________________________________________
ruby-dev メーリングリスト -- ruby-dev@ml.ruby-lang.org
配信停止は ruby-dev-leave@ml.ruby-lang.org にメールをお送りください。
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-dev:52166] [Ruby Bug#21608] 三項演算子と break を組み合わせると SyntaxError
2025-09-17 0:25 [ruby-dev:52164] [Ruby Bug#21608] 三項演算子と break を組み合わせると SyntaxError ursm (Keita Urashima) - ruby-dev 経由
2025-09-17 0:53 ` [ruby-dev:52165] " kddnewton (Kevin Newton) - ruby-dev 経由
@ 2025-09-17 4:42 ` nobu (Nobuyoshi Nakada) - ruby-dev 経由
2025-09-17 5:33 ` [ruby-dev:52167] " Earlopain (Earlopain _) - ruby-dev 経由
2 siblings, 0 replies; 4+ messages in thread
From: nobu (Nobuyoshi Nakada) - ruby-dev 経由 @ 2025-09-17 4:42 UTC (permalink / raw)
To: ruby-dev; +Cc: nobu (Nobuyoshi Nakada)
Issue #21608 has been updated by nobu (Nobuyoshi Nakada).
Status changed from Open to Rejected
In ruby code, operations with arguments without parentheses have quite lower precedence.
That code is inverting the precedences, so this failure should be an intentional fix.
----------------------------------------
Bug #21608: 三項演算子と break を組み合わせると SyntaxError
https://bugs.ruby-lang.org/issues/21608#change-114648
* Author: ursm (Keita Urashima)
* Status: Rejected
* Assignee: prism
* ruby -v: ruby 3.4.6 (2025-09-16 revision dbd83256b1) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: REQUIRED
----------------------------------------
```
>> RUBY_VERSION
=> "3.4.5"
>> [1, 2].find {|i| i.even? ? break i : nil }
```
```
>> RUBY_VERSION
=> "3.4.6"
>> [1, 2].find {|i| i.even? ? break i : nil }
<internal:kernel>:168:in 'Kernel#loop': (irb):2: syntax error found (SyntaxError)
> 2 | ... i : nil }
| ^ unexpected local variable or method, expecting end-of-input
from /home/ursm/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/gems/irb-1.15.2/exe/irb:9:in '<top (required)>'
from /home/ursm/.local/share/mise/installs/ruby/3.4.6/bin/irb:25:in 'Kernel#load'
from /home/ursm/.local/share/mise/installs/ruby/3.4.6/bin/irb:25:in '<main>'
```
--
https://bugs.ruby-lang.org/
_______________________________________________
ruby-dev メーリングリスト -- ruby-dev@ml.ruby-lang.org
配信停止は ruby-dev-leave@ml.ruby-lang.org にメールをお送りください。
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-dev:52167] [Ruby Bug#21608] 三項演算子と break を組み合わせると SyntaxError
2025-09-17 0:25 [ruby-dev:52164] [Ruby Bug#21608] 三項演算子と break を組み合わせると SyntaxError ursm (Keita Urashima) - ruby-dev 経由
2025-09-17 0:53 ` [ruby-dev:52165] " kddnewton (Kevin Newton) - ruby-dev 経由
2025-09-17 4:42 ` [ruby-dev:52166] " nobu (Nobuyoshi Nakada) - ruby-dev 経由
@ 2025-09-17 5:33 ` Earlopain (Earlopain _) - ruby-dev 経由
2 siblings, 0 replies; 4+ messages in thread
From: Earlopain (Earlopain _) - ruby-dev 経由 @ 2025-09-17 5:33 UTC (permalink / raw)
To: ruby-dev; +Cc: Earlopain (Earlopain _)
Issue #21608 has been updated by Earlopain (Earlopain _).
To elaborate, if you replace `break` with a method call, it was already a syntax error. I suspect this was changed with https://bugs.ruby-lang.org/issues/21540. Such code has been rejected since at least ruby 2.0 and was only accidentally accepted since 3.4.0
----------------------------------------
Bug #21608: 三項演算子と break を組み合わせると SyntaxError
https://bugs.ruby-lang.org/issues/21608#change-114649
* Author: ursm (Keita Urashima)
* Status: Rejected
* Assignee: prism
* ruby -v: ruby 3.4.6 (2025-09-16 revision dbd83256b1) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: REQUIRED
----------------------------------------
```
>> RUBY_VERSION
=> "3.4.5"
>> [1, 2].find {|i| i.even? ? break i : nil }
```
```
>> RUBY_VERSION
=> "3.4.6"
>> [1, 2].find {|i| i.even? ? break i : nil }
<internal:kernel>:168:in 'Kernel#loop': (irb):2: syntax error found (SyntaxError)
> 2 | ... i : nil }
| ^ unexpected local variable or method, expecting end-of-input
from /home/ursm/.local/share/mise/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/gems/irb-1.15.2/exe/irb:9:in '<top (required)>'
from /home/ursm/.local/share/mise/installs/ruby/3.4.6/bin/irb:25:in 'Kernel#load'
from /home/ursm/.local/share/mise/installs/ruby/3.4.6/bin/irb:25:in '<main>'
```
--
https://bugs.ruby-lang.org/
_______________________________________________
ruby-dev メーリングリスト -- ruby-dev@ml.ruby-lang.org
配信停止は ruby-dev-leave@ml.ruby-lang.org にメールをお送りください。
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-09-17 5:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17 0:25 [ruby-dev:52164] [Ruby Bug#21608] 三項演算子と break を組み合わせると SyntaxError ursm (Keita Urashima) - ruby-dev 経由
2025-09-17 0:53 ` [ruby-dev:52165] " kddnewton (Kevin Newton) - ruby-dev 経由
2025-09-17 4:42 ` [ruby-dev:52166] " nobu (Nobuyoshi Nakada) - ruby-dev 経由
2025-09-17 5:33 ` [ruby-dev:52167] " Earlopain (Earlopain _) - ruby-dev 経由
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).