Project

General

Profile

Actions

Bug #12887

closed

Object#extendを引数無しで呼び出すとErrorとなるが、Module#includeとModule#prependはエラーとならない

Added by takkanm (三村 益隆) about 8 years ago. Updated about 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-dev:49854]

Description

Object#extend を引数無しで呼び出すと、ArgumentErrorとなります。 https://bugs.ruby-lang.org/issues/6085

$ ruby -e 'Module.new { extend }'
-e:1:in `extend': wrong number of arguments (given 0, expected 1+) (ArgumentError)
	from -e:1:in `block in <main>'

しかし、同じように Mix-in する Module#include, Module#prepend を引数なしで呼び出してもエラーとなりません。

$ ruby -e 'Module.new { include }'
$ ruby -e 'Module.new { prepend }'

似たような処理をする関数の引数のチェックは揃っていた方がわかりやすいと思いましたが、いかがでしょうか?

https://github.com/ruby/ruby/pull/1470
https://github.com/takkanm/ruby/tree/check_arity_for_include_and_prepend

Actions #1

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

  • Status changed from Open to Closed

Applied in changeset r56631.


include and prepend check no args

  • eval.c (rb_mod_include, rb_mod_prepend): check if arguments are
    given, as well as Kernel#extend. [ruby-dev:49854] [Bug #12887]
    [Fix GH-1470]
Actions

Also available in: Atom PDF

Like0
Like0