summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--defs/id.def6
-rw-r--r--include/ruby/intern.h2
-rw-r--r--proc.c30
-rw-r--r--test/ruby/test_proc.rb11
-rw-r--r--version.h2
-rw-r--r--vm.c2
7 files changed, 45 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 92ae950ce8..4ad97d221b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Wed Jun 19 03:54:04 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * defs/id.def (predefined): add "idProc".
+
+ * proc.c (mnew, mproc, mlambda): use predefined IDs.
+
+ * vm.c (Init_VM): ditto.
+
+Wed Jun 19 03:54:04 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * include/ruby/intern.h (rb_block_lambda): add declaration instead of
+ deprecated rb_f_lambda.
+
Wed Jun 19 03:24:07 2013 Kazuki Tsujimoto <kazuki@callcc.net>
* include/ruby/ruby.h, vm_eval.c (rb_funcall_with_block):
diff --git a/defs/id.def b/defs/id.def
index ea0746e4d6..91c4110d24 100644
--- a/defs/id.def
+++ b/defs/id.def
@@ -7,6 +7,7 @@ firstline, predefined = __LINE__+1, %[\
gets
succ
each
+ proc
lambda
send
__send__
@@ -48,7 +49,10 @@ const_ids = []
class_ids = []
names = {}
predefined.split(/^/).each_with_index do |line, num|
- next if /^#/ =~ line or (name, token = line.split; !name)
+ next if /^#/ =~ line
+ line.sub!(/\s+#.*/, '')
+ name, token = line.split
+ next unless name
token ||= name
if /#/ =~ token
token = "_#{token.gsub(/\W+/, '_')}"
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 1c12b2e2fd..38c41757ae 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -382,7 +382,7 @@ VALUE rb_require_safe(VALUE, int);
void rb_obj_call_init(VALUE, int, VALUE*);
VALUE rb_class_new_instance(int, VALUE*, VALUE);
VALUE rb_block_proc(void);
-VALUE rb_f_lambda(void);
+VALUE rb_block_lambda(void);
VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE);
VALUE rb_obj_is_proc(VALUE);
VALUE rb_proc_call(VALUE, VALUE);
diff --git a/proc.c b/proc.c
index dad0ace90e..41908d5b94 100644
--- a/proc.c
+++ b/proc.c
@@ -481,6 +481,14 @@ rb_block_proc(void)
return proc_new(rb_cProc, FALSE);
}
+/*
+ * call-seq:
+ * lambda { |...| block } -> a_proc
+ *
+ * Equivalent to <code>Proc.new</code>, except the resulting Proc objects
+ * check the number of parameters passed when called.
+ */
+
VALUE
rb_block_lambda(void)
{
@@ -494,20 +502,6 @@ rb_f_lambda(void)
return rb_block_lambda();
}
-/*
- * call-seq:
- * lambda { |...| block } -> a_proc
- *
- * Equivalent to <code>Proc.new</code>, except the resulting Proc objects
- * check the number of parameters passed when called.
- */
-
-static VALUE
-proc_lambda(void)
-{
- return rb_block_lambda();
-}
-
/* Document-method: ===
*
* call-seq:
@@ -952,7 +946,7 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
again:
me = rb_method_entry_without_refinements(klass, id, &defined_class);
if (UNDEFINED_METHOD_ENTRY_P(me)) {
- ID rmiss = rb_intern("respond_to_missing?");
+ ID rmiss = idRespond_to_missing;
VALUE sym = ID2SYM(id);
if (obj != Qundef && !rb_method_basic_definition_p(klass, rmiss)) {
@@ -1993,13 +1987,13 @@ method_inspect(VALUE method)
static VALUE
mproc(VALUE method)
{
- return rb_funcall(Qnil, rb_intern("proc"), 0);
+ return rb_funcall2(rb_mRubyVMFrozenCore, idProc, 0, 0);
}
static VALUE
mlambda(VALUE method)
{
- return rb_funcall(Qnil, rb_intern("lambda"), 0);
+ return rb_funcall(rb_mRubyVMFrozenCore, idLambda, 0, 0);
}
static VALUE
@@ -2339,7 +2333,7 @@ Init_Proc(void)
/* utility functions */
rb_define_global_function("proc", rb_block_proc, 0);
- rb_define_global_function("lambda", proc_lambda, 0);
+ rb_define_global_function("lambda", rb_block_lambda, 0);
/* Method */
rb_cMethod = rb_define_class("Method", rb_cObject);
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 9bd717153e..2db9108534 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -1,4 +1,5 @@
require 'test/unit'
+require_relative 'envutil'
class TestProc < Test::Unit::TestCase
def setup
@@ -1196,4 +1197,14 @@ class TestProc < Test::Unit::TestCase
assert_equal('zot', o.method(:foo).to_proc.() {'zot'}, bug3792)
}
end
+
+ def test_overriden_lambda
+ bug8345 = '[ruby-core:54687] [Bug #8345]'
+ assert_normal_exit('def lambda; end; method(:puts).to_proc', bug8345)
+ end
+
+ def test_overriden_proc
+ bug8345 = '[ruby-core:54688] [Bug #8345]'
+ assert_normal_exit('def proc; end; ->{}.curry', bug8345)
+ end
end
diff --git a/version.h b/version.h
index 385e401364..6092ba0889 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2013-06-19"
-#define RUBY_PATCHLEVEL 231
+#define RUBY_PATCHLEVEL 232
#define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 6
diff --git a/vm.c b/vm.c
index c2b18b56ae..b6c40e7a7a 100644
--- a/vm.c
+++ b/vm.c
@@ -2260,6 +2260,8 @@ Init_VM(void)
rb_define_method_id(klass, id_core_hash_merge_ary, m_core_hash_merge_ary, 2);
rb_define_method_id(klass, id_core_hash_merge_ptr, m_core_hash_merge_ptr, -1);
rb_define_method_id(klass, id_core_hash_merge_kwd, m_core_hash_merge_kwd, 2);
+ rb_define_method_id(klass, idProc, rb_block_proc, 0);
+ rb_define_method_id(klass, idLambda, rb_block_lambda, 0);
rb_obj_freeze(fcore);
rb_gc_register_mark_object(fcore);
rb_mRubyVMFrozenCore = fcore;