< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #14909 has been updated by AlexWayfer (Alexander Popov).
There are problems with Sequel Models, which have `#to_hash` method (implic=
it conversion), and Memery gem, which defines methods with `*args, **kwargs=
, &block` (`**kwargs` was added after warning from Ruby 2.7).
So, Sequel Models as arguments for memoized methods becomes Hashes and it b=
reaks everything.
The `**(;{})` approach is:
* unclear for me (what it does in Ruby?);
* additional changes at every call;
* offenses RuboCop (should be resolved there, yes).
I'll try to make dynamic methods definition in Memery with exactly expected=
parameters instead of `*args, **kwargs, &block`, but it's harder.
----------------------------------------
Bug #14909: Method call with object that has to_hash method crashes (method=
with splat and keyword arguments)
https://bugs.ruby-lang.org/issues/14909#change-84178
* Author: johannes_luedke (Johannes L=FCdke)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin17]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
In a method with a splat method argument followed by a keyword argument, it=
leads to an `ArgumentError` when calling the method with an object that re=
acts to `to_hash`
~~~ruby
def my_func(*objects, error_code: 400)
objects.inspect
end
class Test
def to_hash
# an example hash
{ to_hash_key: "to_hash" }
end
end
my_func(Test.new)
~~~
Observed result: an exception is raised: `in my_func: unknown keyword: to_h=
ash_key (ArgumentError)` =
Expected result: `[#<Test:0x007fc8c9825318>]` is returned by the `my_func` =
call
It should behave the same when calling with objects that have a `to_hash` m=
ethod and objects that don't, shouldn't it?
-- =
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>