[ruby-core:120233] [Ruby master Bug#20952] A weird error message for []= with keyword arguments
From:
"zverok (Victor Shepelev) via ruby-core" <ruby-core@...>
Date:
2024-12-13 19:47:39 UTC
List:
ruby-core #120233
Issue #20952 has been reported by zverok (Victor Shepelev).
----------------------------------------
Bug #20952: A weird error message for []= with keyword arguments
https://bugs.ruby-lang.org/issues/20952
* Author: zverok (Victor Shepelev)
* Status: Open
* Backport: 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONTNEED
----------------------------------------
Trying to document the new deprecation of `#[]=` with keyword arguments, I wrote this sample code:
```ruby
class MyMatrix
# ...some implementation
def []=(*args, **kwargs)
p(args:, kwargs:)
# ...some implementation
end
end
matrix = MyMatrix.new
matrix[5, axis: :y] = 8
```
This fails as expected, but the error message is totally unexpected for me:
```
ruby3_4.rb:11:in '<main>': undefined method '[]=' for an instance of Integer (NoMethodError)
matrix[5, axis: :y] = 8
^^^^^^^^^^^^^^^
```
Am I missing some interpretation peculiarity here?..
```
$ ruby -v
ruby 3.4.0dev (2024-12-11T19:50:20Z master 34e68548d4) +PRISM [x86_64-linux]
```
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/