From: "zverok (Victor Shepelev) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "zverok (Victor Shepelev)" <noreply@ruby-lang.org>
Subject: [ruby-core:120233] [Ruby master Bug#20952] A weird error message for []= with keyword arguments
Date: Fri, 13 Dec 2024 19:47:39 +0000 (UTC) [thread overview]
Message-ID: <redmine.issue-20952.20241213194739.710@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-20952.20241213194739.710@ruby-lang.org>
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/
next parent reply other threads:[~2024-12-13 19:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-13 19:47 zverok (Victor Shepelev) via ruby-core [this message]
2024-12-13 20:01 ` [ruby-core:120234] " jeremyevans0 (Jeremy Evans) via ruby-core
2024-12-13 20:53 ` [ruby-core:120235] " jeremyevans0 (Jeremy Evans) via ruby-core
2024-12-13 21:24 ` [ruby-core:120236] " eightbitraptor (Matt V-H) via ruby-core
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.issue-20952.20241213194739.710@ruby-lang.org \
--to=ruby-core@ml.ruby-lang.org \
--cc=noreply@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).