aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-12 11:10:22 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-12 11:10:22 +0000
commitead9b197be96f9eacf462b5539f71c43422495d0 (patch)
tree9b2965a14b6226ab54d0d2a8ad2a6f831454367f
parent56b42dec015337f6a1a30aee1a6e6364ded3e468 (diff)
downloadruby-ead9b197be96f9eacf462b5539f71c43422495d0.tar.gz
* parse.y (f_args): allow post mandatory arguments after optional
arguments. [ruby-dev:29014] * parse.y (new_args_gen): allow post_args without rest_args. * eval.c (formal_assign): ditto. * parse.y (new_args_gen): check post argument duplication. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog23
-rw-r--r--eval.c8
-rw-r--r--parse.y31
-rw-r--r--ruby.h1
4 files changed, 56 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 6d4fd0cdbf..dc804c8a50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Wed Jul 12 20:05:23 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (f_args): allow post mandatory arguments after optional
+ arguments. [ruby-dev:29014]
+
+ * parse.y (new_args_gen): allow post_args without rest_args.
+
+ * eval.c (formal_assign): ditto.
+
+ * parse.y (new_args_gen): check post argument duplication.
+
+Tue Jul 11 20:58:18 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ruby.h: export rb_cMethod. [ruby-talk:201259]
+
Tue Jul 11 19:13:33 2006 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/multi-tk.rb: remove restriction on the class of
@@ -43,6 +58,14 @@ Mon Jul 10 23:37:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
the first value from the result array if response has only one
value.
+Mon Jul 10 22:00:00 2006 Shigeo Kobayashi <shigek@ruby-lang.org>
+
+ * ext/bigdecimal/bigdecimal.c: Allows '_' to appear within
+ digits. [ruby-dev:28872]
+
+ * ext/bigdecimal/lib/bigdecimal/util.rb: Bug in to_r reported by
+ [ruby-list:42533] fixed.
+
Mon Jul 10 19:22:19 2006 Tanaka Akira <akr@fsij.org>
* gc.c (gc_sweep): expand heap earlier.
diff --git a/eval.c b/eval.c
index ad976f4c2e..acd1840be9 100644
--- a/eval.c
+++ b/eval.c
@@ -244,7 +244,7 @@ static void rb_f_END(void);
static struct BLOCK *passing_block(VALUE,struct BLOCK*);
static int block_orphan(struct BLOCK *data);
-static VALUE rb_cMethod;
+VALUE rb_cMethod;
static VALUE rb_cUnboundMethod;
static VALUE umethod_bind(VALUE, VALUE);
static VALUE rb_mod_define_method(int, VALUE*, VALUE);
@@ -5131,7 +5131,7 @@ assign(VALUE self, NODE *lhs, VALUE val, int pcall)
int cnt;
VALUE *p;
- if ((long)(lhs->nd_args) != -1) {
+ if (lhs->nd_args && (long)(lhs->nd_args) != -1) {
assign(self, lhs->nd_args, val, 0);
}
cnt = lhs->nd_head->nd_alen;
@@ -5660,7 +5660,7 @@ formal_assign(VALUE recv, NODE *node, int argc, const VALUE *argv, VALUE *local_
NODE *opt = node->nd_opt;
int ac = argc - npost;
- while (opt && ac) {
+ while (opt && ac > 0) {
assign(recv, opt->nd_head, *argv, 1);
argv++; ac--;
++i;
@@ -8372,7 +8372,7 @@ proc_s_new(int argc, VALUE *argv, VALUE klass)
/*
* call-seq:
- * proc { |...| block } => a_proc
+ * proc {|...| block } => a_proc
*
* Equivalent to <code>Proc.new</code>.
*/
diff --git a/parse.y b/parse.y
index e26fc1eb66..c2d796eaf7 100644
--- a/parse.y
+++ b/parse.y
@@ -3941,6 +3941,14 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
$$ = dispatch5(params, $1, $3, Qnil, Qnil, escape_Qundef($4));
%*/
}
+ | f_arg ',' f_optarg ',' f_post_arg opt_f_block_arg
+ {
+ /*%%%*/
+ $$ = new_args($1, $3, 0, $5, $6);
+ /*%
+ $$ = dispatch5(params, $1, $3, Qnil, $5, escape_Qundef($6));
+ %*/
+ }
| f_arg ',' f_rest_arg opt_f_block_arg
{
/*%%%*/
@@ -3989,6 +3997,14 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
$$ = dispatch5(params, Qnil, $1, Qnil, Qnil, escape_Qundef($2));
%*/
}
+ | f_optarg ',' f_post_arg opt_f_block_arg
+ {
+ /*%%%*/
+ $$ = new_args(0, $1, 0, $3, $4);
+ /*%
+ $$ = dispatch5(params, Qnil, $1, Qnil, $3, escape_Qundef($4));
+ %*/
+ }
| f_rest_arg opt_f_block_arg
{
/*%%%*/
@@ -4089,7 +4105,7 @@ f_arg : f_norm_arg
VALUE arg = ID2SYM($3);
$$ = $1;
if (rb_ary_includes($$, arg)) {
- yyerror("duplicated argument arg");
+ yyerror("duplicated argument name");
}
rb_ary_push($$, arg);
/*%
@@ -7898,9 +7914,18 @@ new_args_gen(struct parser_params *parser, VALUE m, NODE *o, NODE *r, NODE *p, N
yyerror("duplicated rest argument name");
return 0;
}
- if (p) {
- r = NEW_POSTARG(r, p);
+ }
+ if (p) {
+ node = p;
+ while (node) {
+ if (!node->nd_head) break;
+ if (arg_dup_check(node->nd_head->nd_vid, m, list, node)) {
+ yyerror("duplicated argument name");
+ return 0;
+ }
+ node = node->nd_next;
}
+ r = NEW_POSTARG(r, p);
}
node = NEW_ARGS(m, o, r);
if (b) {
diff --git a/ruby.h b/ruby.h
index b0a0e3e7b9..28be3d3df2 100644
--- a/ruby.h
+++ b/ruby.h
@@ -654,6 +654,7 @@ RUBY_EXTERN VALUE rb_cFloat;
RUBY_EXTERN VALUE rb_cHash;
RUBY_EXTERN VALUE rb_cInteger;
RUBY_EXTERN VALUE rb_cIO;
+RUBY_EXTERN VALUE rb_cMethod;
RUBY_EXTERN VALUE rb_cModule;
RUBY_EXTERN VALUE rb_cNilClass;
RUBY_EXTERN VALUE rb_cNumeric;