Project

General

Profile

Bug #7662

Unable to define a method with bare `**`

Added by wycats (Yehuda Katz) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
[ruby-core:51269]

Description

This works:

def foo(*)
end

This does not:

def foo(**)
end

This does not:

def foo(, *)
end

I use bare * often in combination with bare super to extend a superclass without being brittle to its exact signature. With keyword arguments, this seems like it will be impossible. I am opening several other related issues.

Associated revisions

Revision 38725
Added by nobu (Nobuyoshi Nakada) over 4 years ago

parse.y: bare kwrest_mark

  • parse.y (f_kwrest): allow bare kwrest_mark as valid syntax. its semantics is still undefined. [Bug #7662]

Revision 38725
Added by nobu (Nobuyoshi Nakada) over 4 years ago

parse.y: bare kwrest_mark

  • parse.y (f_kwrest): allow bare kwrest_mark as valid syntax. its semantics is still undefined. [Bug #7662]

Revision 38725
Added by nobu (Nobuyoshi Nakada) over 4 years ago

parse.y: bare kwrest_mark

  • parse.y (f_kwrest): allow bare kwrest_mark as valid syntax. its semantics is still undefined. [Bug #7662]

Revision 38725
Added by nobu (Nobuyoshi Nakada) over 4 years ago

parse.y: bare kwrest_mark

  • parse.y (f_kwrest): allow bare kwrest_mark as valid syntax. its semantics is still undefined. [Bug #7662]

History

#1 [ruby-core:51275] Updated by matz (Yukihiro Matsumoto) over 4 years ago

  • Target version set to next minor
  • Assignee set to nobu (Nobuyoshi Nakada)

I consider this as a bug. Since it's minor issue, I defer fix to next minor.

Matz.

#2 [ruby-core:51280] Updated by nobu (Nobuyoshi Nakada) over 4 years ago

=begin
You don't need (({**})) here.

A rest argument includes keyword hash if the method does not have keyrest argument.
=end

#3 [ruby-core:51281] Updated by charliesome (Charlie Somerville) over 4 years ago

=begin
I think this is important for consistency. Consider:

def f(a, b, **)
# ...
super
end
=end

#4 [ruby-core:51282] Updated by mame (Yusuke Endoh) over 4 years ago

  • Status changed from Open to Assigned

Thanks for your feedback. I'm neutral for bare ** itself.
But it is too late a bit to discuss the spec and there is an obvious workaround:

def foo(**dummy)
end

Of course, we can add bare `**' later (say, in 2.0.1).

BTW:

I use bare * often in combination with bare super to extend a superclass without being brittle to its exact signature.

I don't think that it is a good idea to ignore arguments silently just for a bare super.
You should call super with explicit argument delegation if your overriding method changes the signature of its parent method.

#5 Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • % Done changed from 0 to 100
  • Status changed from Assigned to Closed

This issue was solved with changeset r38725.
Yehuda, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


parse.y: bare kwrest_mark

  • parse.y (f_kwrest): allow bare kwrest_mark as valid syntax. its semantics is still undefined. [Bug #7662]

Also available in: Atom PDF