[ruby-core:95810] [Ruby master Bug#16344] Can be assigned to numbered parameter when after used _1

From: hanmac@...
Date: 2019-11-12 08:47:58 UTC
List: ruby-core #95810
Issue #16344 has been updated by Hanmac (Hans Mackowiak).


i think this has something to do with that _* parameter doesn't cause duplicate syntax errors:

```ruby
def abc(_x,_x)
  p _x
end

abc("y","z") #=> "y"
```

See some of your examples from #16293

----------------------------------------
Bug #16344: Can be assigned to numbered parameter when after used _1
https://bugs.ruby-lang.org/issues/16344#change-82636

* Author: osyo (manga osyo)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-11-11T23:39:38Z trunk 2407e89725) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
## Steps to reproduce

1. Define local variable `_1` outside block
2. Call Numbered parameter in block
3. Assign for `_1`


## Expected behavior

```ruby
_1 = :local_variable
proc {
  _1
  # Error: Can't assign to numbered parameter _1
  _1 = 42
}
```


## Actual behavior

```ruby
_1 = :local_variable
proc {
  _1
  # No error
  _1 = 42
}
```

Cannot be assinged to numbered parameter from #16293.
However, can be assinged to numbered parameter if defined local variable _1 outside block.
I think this is a bug.







-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next