ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:115517] [Ruby master Bug#20026] Ruby doesn't throw a syntax error when rescuing with ||
@ 2023-11-28 17:46 arian (Arian Faurtosh) via ruby-core
  2023-11-28 17:49 ` [ruby-core:115518] " arian (Arian Faurtosh) via ruby-core
  2023-11-29  6:35 ` [ruby-core:115530] " nobu (Nobuyoshi Nakada) via ruby-core
  0 siblings, 2 replies; 3+ messages in thread
From: arian (Arian Faurtosh) via ruby-core @ 2023-11-28 17:46 UTC (permalink / raw
  To: ruby-core; +Cc: arian (Arian Faurtosh)

Issue #20026 has been reported by arian (Arian Faurtosh).

----------------------------------------
Bug #20026: Ruby doesn't throw a syntax error when rescuing with ||
https://bugs.ruby-lang.org/issues/20026

* Author: arian (Arian Faurtosh)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin23]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
We had a coworker new to ruby try an interesting syntax for rescue that doesn't result in a syntax error, and works partially.

Why does ruby allow the logical OR || operator, is there a purpose for this? If not this feels like it should be a syntax error, instead of resulting in partially working code.

``` ruby
class FooError < StandardError; end
class BarError < StandardError; end

# works
begin
  raise FooError
rescue FooError || BarError => e
  puts "rescued #{e.class}"
end

# doesn't work
begin
  raise FooError
rescue FooError || BarError => e
  puts "rescued #{e.class}"
end
```




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:115518] [Ruby master Bug#20026] Ruby doesn't throw a syntax error when rescuing with ||
  2023-11-28 17:46 [ruby-core:115517] [Ruby master Bug#20026] Ruby doesn't throw a syntax error when rescuing with || arian (Arian Faurtosh) via ruby-core
@ 2023-11-28 17:49 ` arian (Arian Faurtosh) via ruby-core
  2023-11-29  6:35 ` [ruby-core:115530] " nobu (Nobuyoshi Nakada) via ruby-core
  1 sibling, 0 replies; 3+ messages in thread
From: arian (Arian Faurtosh) via ruby-core @ 2023-11-28 17:49 UTC (permalink / raw
  To: ruby-core; +Cc: arian (Arian Faurtosh)

Issue #20026 has been updated by arian (Arian Faurtosh).


Actually I see what's going on here, this can be closed, not actually a ruby issue.

`FooError || BarError` is evaluating to `FooError`

----------------------------------------
Bug #20026: Ruby doesn't throw a syntax error when rescuing with ||
https://bugs.ruby-lang.org/issues/20026#change-105446

* Author: arian (Arian Faurtosh)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin23]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
We had a coworker new to ruby try an interesting syntax for rescue that doesn't result in a syntax error, and works partially.

Why does ruby allow the logical OR || operator, is there a purpose for this? If not this feels like it should be a syntax error, instead of resulting in partially working code.

``` ruby
class FooError < StandardError; end
class BarError < StandardError; end

# works
begin
  raise FooError
rescue FooError || BarError => e
  puts "rescued #{e.class}"
end

# doesn't work
begin
  raise FooError
rescue FooError || BarError => e
  puts "rescued #{e.class}"
end
```




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:115530] [Ruby master Bug#20026] Ruby doesn't throw a syntax error when rescuing with ||
  2023-11-28 17:46 [ruby-core:115517] [Ruby master Bug#20026] Ruby doesn't throw a syntax error when rescuing with || arian (Arian Faurtosh) via ruby-core
  2023-11-28 17:49 ` [ruby-core:115518] " arian (Arian Faurtosh) via ruby-core
@ 2023-11-29  6:35 ` nobu (Nobuyoshi Nakada) via ruby-core
  1 sibling, 0 replies; 3+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2023-11-29  6:35 UTC (permalink / raw
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #20026 has been updated by nobu (Nobuyoshi Nakada).


You may want to write:

```ruby
begin
  raise FooError
rescue FooError, BarError => e
  puts "rescued #{e.class}"
end
```

----------------------------------------
Bug #20026: Ruby doesn't throw a syntax error when rescuing with ||
https://bugs.ruby-lang.org/issues/20026#change-105462

* Author: arian (Arian Faurtosh)
* Status: Rejected
* Priority: Normal
* ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin23]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
We had a coworker new to ruby try an interesting syntax for rescue that doesn't result in a syntax error, and works partially.

Why does ruby allow the logical OR || operator, is there a purpose for this? If not this feels like it should be a syntax error, instead of resulting in partially working code.

``` ruby
class FooError < StandardError; end
class BarError < StandardError; end

# works
begin
  raise FooError
rescue FooError || BarError => e
  puts "rescued #{e.class}"
end

# doesn't work
begin
  raise FooError
rescue FooError || BarError => e
  puts "rescued #{e.class}"
end
```




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-29  6:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-28 17:46 [ruby-core:115517] [Ruby master Bug#20026] Ruby doesn't throw a syntax error when rescuing with || arian (Arian Faurtosh) via ruby-core
2023-11-28 17:49 ` [ruby-core:115518] " arian (Arian Faurtosh) via ruby-core
2023-11-29  6:35 ` [ruby-core:115530] " nobu (Nobuyoshi Nakada) via ruby-core

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 read-only IMAP folder(s) and NNTP newsgroup(s).