Project

General

Profile

Actions

Bug #18629

closed

block args array splatting assigns to higher scope _ var

Added by Nakilon (Victor Maslov) about 2 years ago. Updated about 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:107883]

Description

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)

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0