[ruby-core:94213] [Ruby master Bug#8279] Single-line rescue parsing

From: merch-redmine@...
Date: 2019-08-09 03:12:04 UTC
List: ruby-core #94213
Issue #8279 has been updated by jeremyevans0 (Jeremy Evans).

File massign-rescue-modifier-8279.patch added

This bug is still present in the master branch. Attached is a patch that fixes it, so that multiple assignment with rescue modifier is consistent with single assignment with rescue modifier.  After the patch:

```
a = raise rescue 1 # a = (raise rescue 1)
a, b = raise rescue [1, 2] # a, b = (raise rescue [1, 2])
```

----------------------------------------
Bug #8279: Single-line rescue parsing
https://bugs.ruby-lang.org/issues/8279#change-80511

* Author: dunric (David Unric)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
* ruby -v: 2.0.0p0
* Backport: 
----------------------------------------
Hi,

there seems to be a bug in parser for single-line rescue statement. It fails in case of multiple assignment statements, keeping operator precedence vs. simple assignment etc.

obj = expression rescue objval
# parsed as
obj = (expression rescue objval) 

obj1, obj2 = expression rescue [objval1, objval2]
# parsed as
(obj1, obj2 = expression) rescue [objval1, objval2]

obj += expression rescue objval
# parsed as
obj += (expression rescue objval)

obj = obj + expression rescue objval
# parsed as
obj = (obj + expression) rescue objval


There is already a thread about this issue on ruby-forum.com, even Matz himself is aware and did gave a nod to this problem http://www.ruby-forum.com/topic/152260#671711 , though nothing was done to fix it yet.

I've tried to report about this problem once (http://bugs.ruby-lang.org/issues/8239) but it was ignored for no known reason.


---Files--------------------------------
massign-rescue-modifier-8279.patch (2.08 KB)


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