ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:120738] [Ruby master Bug#21048] [Prism] rescue in modifier form with condition behaves differently
@ 2025-01-19 13:31 Earlopain (Earlopain _) via ruby-core
  2025-01-20  5:01 ` [ruby-core:120741] " nobu (Nobuyoshi Nakada) via ruby-core
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2025-01-19 13:31 UTC (permalink / raw)
  To: ruby-core; +Cc: Earlopain (Earlopain _)

Issue #21048 has been reported by Earlopain (Earlopain _).

----------------------------------------
Bug #21048: [Prism] rescue in modifier form with condition behaves differently
https://bugs.ruby-lang.org/issues/21048

* Author: Earlopain (Earlopain _)
* Status: Open
* ruby -v: 3.4.1
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
With the following code there is a discrepancy in how prism and parse.y consider precedence:

```rb
$called = false
def foo
  $called = true
end

foo rescue nil if false

puts "Called: #{$called}"
```

Prism interprets it as `(foo rescue nil) if false`, not calling the method. `parse.y` does `foo rescue (nil if false)` since at least Ruby 2.0

```sh
$ ruby -v
ruby 3.5.0dev (2025-01-19T12:44:20Z master f27ed98eff) +PRISM [x86_64-linux]

$ ruby code.rb
Called: true

$ ruby --parser=parse.y code.rb
Called: false
```



-- 
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/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:120741] [Ruby master Bug#21048] [Prism] rescue in modifier form with condition behaves differently
  2025-01-19 13:31 [ruby-core:120738] [Ruby master Bug#21048] [Prism] rescue in modifier form with condition behaves differently Earlopain (Earlopain _) via ruby-core
@ 2025-01-20  5:01 ` nobu (Nobuyoshi Nakada) via ruby-core
  2025-01-20  6:41 ` [ruby-core:120742] " Earlopain (Earlopain _) via ruby-core
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2025-01-20  5:01 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

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


Earlopain (Earlopain _) wrote:
> Prism interprets it as `(foo rescue nil) if false`, not calling the method. `parse.y` does `foo rescue (nil if false)` since at least Ruby 2.0

Inverse?

> ```sh
> $ ruby -v
> ruby 3.5.0dev (2025-01-19T12:44:20Z master f27ed98eff) +PRISM [x86_64-linux]
> 
> $ ruby code.rb
> Called: true
> 
> $ ruby --parser=parse.y code.rb
> Called: false
> ```



----------------------------------------
Bug #21048: [Prism] rescue in modifier form with condition behaves differently
https://bugs.ruby-lang.org/issues/21048#change-111572

* Author: Earlopain (Earlopain _)
* Status: Open
* ruby -v: ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
With the following code there is a discrepancy in how prism and parse.y consider precedence:

```rb
$called = false
def foo
  $called = true
end

foo rescue nil if false

puts "Called: #{$called}"
```

Prism interprets it as `(foo rescue nil) if false`, not calling the method. `parse.y` does `foo rescue (nil if false)` since at least Ruby 2.0

```sh
$ ruby -v
ruby 3.5.0dev (2025-01-19T12:44:20Z master f27ed98eff) +PRISM [x86_64-linux]

$ ruby code.rb
Called: true

$ ruby --parser=parse.y code.rb
Called: false
```



-- 
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/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:120742] [Ruby master Bug#21048] [Prism] rescue in modifier form with condition behaves differently
  2025-01-19 13:31 [ruby-core:120738] [Ruby master Bug#21048] [Prism] rescue in modifier form with condition behaves differently Earlopain (Earlopain _) via ruby-core
  2025-01-20  5:01 ` [ruby-core:120741] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2025-01-20  6:41 ` Earlopain (Earlopain _) via ruby-core
  2025-01-21 18:23 ` [ruby-core:120751] " tenderlovemaking (Aaron Patterson) via ruby-core
  2025-01-22 20:48 ` [ruby-core:120761] " kddnewton (Kevin Newton) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2025-01-20  6:41 UTC (permalink / raw)
  To: ruby-core; +Cc: Earlopain (Earlopain _)

Issue #21048 has been updated by Earlopain (Earlopain _).


Yes, I switched it up in the text. Fixed

----------------------------------------
Bug #21048: [Prism] rescue in modifier form with condition behaves differently
https://bugs.ruby-lang.org/issues/21048#change-111573

* Author: Earlopain (Earlopain _)
* Status: Open
* ruby -v: ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
With the following code there is a discrepancy in how prism and parse.y consider precedence:

```rb
$called = false
def foo
  $called = true
end

foo rescue nil if false

puts "Called: #{$called}"
```

Prism interprets it as `(foo rescue nil) if false`, not calling the method. `parse.y` does `foo rescue (nil if false)` since at least Ruby 2.0

```sh
$ ruby -v
ruby 3.5.0dev (2025-01-19T12:44:20Z master f27ed98eff) +PRISM [x86_64-linux]

$ ruby code.rb
Called: true

$ ruby --parser=parse.y code.rb
Called: false
```



-- 
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/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:120751] [Ruby master Bug#21048] [Prism] rescue in modifier form with condition behaves differently
  2025-01-19 13:31 [ruby-core:120738] [Ruby master Bug#21048] [Prism] rescue in modifier form with condition behaves differently Earlopain (Earlopain _) via ruby-core
  2025-01-20  5:01 ` [ruby-core:120741] " nobu (Nobuyoshi Nakada) via ruby-core
  2025-01-20  6:41 ` [ruby-core:120742] " Earlopain (Earlopain _) via ruby-core
@ 2025-01-21 18:23 ` tenderlovemaking (Aaron Patterson) via ruby-core
  2025-01-22 20:48 ` [ruby-core:120761] " kddnewton (Kevin Newton) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: tenderlovemaking (Aaron Patterson) via ruby-core @ 2025-01-21 18:23 UTC (permalink / raw)
  To: ruby-core; +Cc: tenderlovemaking (Aaron Patterson)

Issue #21048 has been updated by tenderlovemaking (Aaron Patterson).

Assignee set to prism

----------------------------------------
Bug #21048: [Prism] rescue in modifier form with condition behaves differently
https://bugs.ruby-lang.org/issues/21048#change-111614

* Author: Earlopain (Earlopain _)
* Status: Open
* Assignee: prism
* ruby -v: ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
With the following code there is a discrepancy in how prism and parse.y consider precedence:

```rb
$called = false
def foo
  $called = true
end

foo rescue nil if false

puts "Called: #{$called}"
```

Prism interprets it as `foo rescue (nil if false)`, calling the method. `parse.y` does `(foo rescue nil) if false` since at least Ruby 2.0

```sh
$ ruby -v
ruby 3.5.0dev (2025-01-19T12:44:20Z master f27ed98eff) +PRISM [x86_64-linux]

$ ruby code.rb
Called: true

$ ruby --parser=parse.y code.rb
Called: false
```



-- 
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/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:120761] [Ruby master Bug#21048] [Prism] rescue in modifier form with condition behaves differently
  2025-01-19 13:31 [ruby-core:120738] [Ruby master Bug#21048] [Prism] rescue in modifier form with condition behaves differently Earlopain (Earlopain _) via ruby-core
                   ` (2 preceding siblings ...)
  2025-01-21 18:23 ` [ruby-core:120751] " tenderlovemaking (Aaron Patterson) via ruby-core
@ 2025-01-22 20:48 ` kddnewton (Kevin Newton) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2025-01-22 20:48 UTC (permalink / raw)
  To: ruby-core; +Cc: kddnewton (Kevin Newton)

Issue #21048 has been updated by kddnewton (Kevin Newton).

Status changed from Open to Closed

Fixed by https://github.com/ruby/ruby/commit/c2908613368b2ae404d094a15df61d830fc46dc9

----------------------------------------
Bug #21048: [Prism] rescue in modifier form with condition behaves differently
https://bugs.ruby-lang.org/issues/21048#change-111626

* Author: Earlopain (Earlopain _)
* Status: Closed
* Assignee: prism
* ruby -v: ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: REQUIRED
----------------------------------------
With the following code there is a discrepancy in how prism and parse.y consider precedence:

```rb
$called = false
def foo
  $called = true
end

foo rescue nil if false

puts "Called: #{$called}"
```

Prism interprets it as `foo rescue (nil if false)`, calling the method. `parse.y` does `(foo rescue nil) if false` since at least Ruby 2.0

```sh
$ ruby -v
ruby 3.5.0dev (2025-01-19T12:44:20Z master f27ed98eff) +PRISM [x86_64-linux]

$ ruby code.rb
Called: true

$ ruby --parser=parse.y code.rb
Called: false
```



-- 
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/lists/ruby-core.ml.ruby-lang.org/

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

end of thread, other threads:[~2025-01-22 20:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-19 13:31 [ruby-core:120738] [Ruby master Bug#21048] [Prism] rescue in modifier form with condition behaves differently Earlopain (Earlopain _) via ruby-core
2025-01-20  5:01 ` [ruby-core:120741] " nobu (Nobuyoshi Nakada) via ruby-core
2025-01-20  6:41 ` [ruby-core:120742] " Earlopain (Earlopain _) via ruby-core
2025-01-21 18:23 ` [ruby-core:120751] " tenderlovemaking (Aaron Patterson) via ruby-core
2025-01-22 20:48 ` [ruby-core:120761] " kddnewton (Kevin Newton) 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 NNTP newsgroup(s).