[ruby-core:94221] [Ruby master Bug#16092] [doc] precedence of modifier-rescue

From: daniel@...42.com
Date: 2019-08-09 14:18:36 UTC
List: ruby-core #94221
Issue #16092 has been reported by Dan0042 (Daniel DeLorme).

----------------------------------------
Bug #16092: [doc] precedence of modifier-rescue
https://bugs.ruby-lang.org/issues/16092

* Author: Dan0042 (Daniel DeLorme)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
The docs state that modifier-rescue has lower precedence than assignments which have lower precedence than modifier-if. This is true for
`v = expr rescue $! if condition` but not for
`v = expr if condition rescue $!` which is treated as
`(v = expr if condition) rescue $!` rather than
`v = expr if (condition rescue $!)`

This goes similarly for
`defined? expr rescue $!` 
`not expr rescue $!`
`expr1 and expr2 rescue $!`
`expr1 or expr2 rescue $!`

So maybe the documentation should state that modifier-rescue has **equal** precedence to modifier-if & others, with an **exception** made for assignments? I'm not entirely sure how to describe that exception though.



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

Prev Next