From: "jeremyevans0 (Jeremy Evans)" Date: 2022-03-13T16:57:42+00:00 Subject: [ruby-core:107884] [Ruby master Bug#18629] block args array splatting assigns to higher scope _ var Issue #18629 has been updated by jeremyevans0 (Jeremy Evans). I'm guessing this isn't a bug, because variables prefixed by `_` (including `_` itself) are supposed to be used in cases where you are ignoring the values. There are other cases where `_` prefixed variables are special: ```ruby def a(b, b) end # SyntaxError def a(_b, _b) end # no error ``` ---------------------------------------- Bug #18629: block args array splatting assigns to higher scope _ var https://bugs.ruby-lang.org/issues/18629#change-96825 * Author: Nakilon (Victor Maslov) * Status: Open * Priority: Normal * ruby -v: 3.0.2 * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- ``` ruby v = 1; [[2]].each{ |(v)| }; p v _ = 1; [[2]].each{ |(_)| }; p _ ``` prints ``` 1 2 ``` You can see here that `v` is still `1` but `_` isn't shadowed properly and is being assigned `2`. Reproducible from 2.3.8 to 3.0.2 (macOS rbenv) -- https://bugs.ruby-lang.org/ Unsubscribe: