[#88925] [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical — ko1@...
Issue #15095 has been updated by ko1 (Koichi Sasada).
4 messages
2018/09/09
[#88927] Re: [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical
— Eric Wong <normalperson@...>
2018/09/09
ko1@atdot.net wrote:
[#88926] [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical — ko1@...
Issue #15095 has been updated by ko1 (Koichi Sasada).
3 messages
2018/09/09
[#89218] [Ruby trunk Bug#15130] open-uri hangs on cygwin — duerst@...
Issue #15130 has been updated by duerst (Martin D端rst).
5 messages
2018/09/30
[ruby-core:88862] [Ruby trunk Bug#12717] Optional argument treated as kwarg
From:
ruby-core@...
Date:
2018-09-05 15:22:52 UTC
List:
ruby-core #88862
Issue #12717 has been updated by marcandre (Marc-Andre Lafortune).
I believe this is as designed.
As I stated previously (https://bugs.ruby-lang.org/issues/11967#note-3), my understanding is that:
* after all mandatory unnamed arguments are filled
* if the last remaining argument is hash-like
* and all its keys are symbols
* and the method called uses keyword arguments => then that parameter is used for keyword arguments.
I believe we should close this issue.
----------------------------------------
Bug #12717: Optional argument treated as kwarg
https://bugs.ruby-lang.org/issues/12717#change-73900
* Author: AMHOL (Andy Holland)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
* ruby -v: 2.3.1
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
When you define a method with an optional argument and keyword arguments (whether explicitly or with options splat) the defaulted argument can not take a hash argument, instead it is interpreted as keyword arguments:
~~~ ruby
class Foo
def self.options(value = nil, **options)
puts value.inspect
puts options.inspect
end
def self.kwarg(value = nil, kw: nil)
puts value.inspect
puts kw.inspect
end
def self.splat(*args, kw: nil)
puts args.inspect
puts kw.inspect
end
end
Foo.options({})
# nil
# {}
Foo.kwarg({})
# nil
# nil
Foo.splat({})
# []
# nil
Foo.options({ key: :value })
# nil
# {:key=>:value}
Foo.kwarg({ key: :value })
# ArgumentError: unknown keyword: key
Foo.splat({ key: :value })
# ArgumentError: unknown keyword: key
~~~
I would expect the output to be:
~~~ ruby
Foo.options({})
# {}
# {}
Foo.kwarg({})
# {}
# nil
Foo.splat({})
# [{}]
# nil
Foo.options({ key: :value })
# {:key=>:value}
# {}
Foo.kwarg({ key: :value })
# {:key=>:value}
# nil
Foo.splat({ key: :value })
# [{:key=>:value}]
# nil
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>